Rafael L Martins
def me(): return " dev* "
Rafael Martins
rafael84@gmail.com
Jan, 2015
$ docker --help Usage: docker [OPTIONS] COMMAND [arg...] A self-sufficient runtime for linux containers.
Server
OS
?
OS
OS
OS
VM
guest os
}
host os
}
VM
VM
HYPERVISOR
A piece of computer software, firmware or hardware that creates and runs virtual machines.
Server
Hypervisor (type 1)
Server
Host OS
Hypervisor (type 2)
vs
Server
Host OS
Hypervisor (type 2)
Guest OS
Guest OS
Bins /
Libs
Bins /
Libs
App
A
App
B
Server
Host OS
Bins / Libs
Bins / Libs
App
A'
vs
App
A'
App
A'
App
A'
App
B'
App
B'
Guest OS
Bins /
Libs
App
A
Container Manager
vs
$ docker --help Usage: docker [OPTIONS] COMMAND [arg...] A self-sufficient runtime for linux containers.
Server
Host OS
Bins / Libs
Bins / Libs
App
A'
App
A'
App
A'
App
A'
App
B'
App
B'
Docker Engine
App
A'
CLI
Rest API
Dockerfiles
Container Manager
Docker
Registry
Docker
HUB (PaaS)
Docker Machine*
Docker Swarm*
FIG Docker Compose*
Images
LAYER
IMAGE
CONTAINER
bootfs
(bootloader, kernel)
rootfs
/dev, /proc, /bin, /etc, /lib, /usr, /tmp
{
Debian
Image
}
layer
layer
}
bootfs
Kernel
Debian
Base Image
CentOS
Base Image
Apache:80
Image
Nginx:80
Image
Writable FS
{
App
A
}
App
B
Writable FS
host-os $ docker search ubuntu
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Official Ubuntu base image 1208 [OK]
host-os $ docker pull ubuntu:latest
host-os $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu latest 9bd07e480c5b 7 weeks ago 192.7 MB
host-os $ docker run -i -t ubuntu /bin/bash
ubuntu $ _
host-os $ docker run -d ubuntu \
> /bin/sh -c "while true; do echo Hello World; sleep 1; done"
fd2827f60bf56d00e0ef21e711df153e05585f27a382bdccaced3dd51921e232
host-os $ _
host-os $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd2827f60bf5 ubuntu:latest "/bin/sh -c 'while t 9 minutes ago Up 8 minutes blue_sky
host-os $ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fd2827f60bf5 ubuntu:latest "/bin/sh -c 'while t 9 minutes ago Up 8 minutes blue_sky
7f60ad3fabf5 ubuntu:latest "/bin/sh -c 'while t 9 minutes ago Exited (-1) 6s red_sea
host-os $ docker stop blue_sky
host-os $ docker start blue_sky
host-os $ docker stop blue_sky
host-os $ docker rm blue_sky
host-os $ docker commit blue_sky sky_img
host-os $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
sky_img latest e480abcedc3b 5 seconds ago 192.7 MB
host-os $ docker --help
...and more...
Docker can build images automatically by reading the instructions from a Dockerfile.
A Dockerfile is a text document that contains all the commands you would normally execute manually in order to build a Docker image.
By calling docker build from your terminal, you can have Docker build your image step by step, executing the instructions successively.
FROM buildpack-deps:sid-curl
RUN apt-get update && apt-get install -y unzip \
&& rm -rf /var/lib/apt/lists/*
ENV JAVA_VERSION 8u40~b22
ENV JAVA_DEBIAN_VERSION 8u40~b22-2
ENV CA_CERTIFICATES_JAVA_VERSION 20140324
RUN apt-get update && apt-get install -y \
openjdk-8-jre-headless="$JAVA_DEBIAN_VERSION" \
ca-certificates-java="$CA_CERTIFICATES_JAVA_VERSION" \
&& rm -rf /var/lib/apt/lists/*
RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
host-os $ docker build -t openjdk-8-jre .
Uploading context 10.24 kB
Uploading context
Step 1 : FROM buildpack-deps:sid-curl
---> cbba202fe96b
Step 2 : RUN apt-get update && apt-get install -y unzip && rm -rf /var/lib/apt/lists/*
---> 51182097be13
...
Step 7 : RUN /var/lib/dpkg/info/ca-certificates-java.postinst configure
Successfully built 1a5ffc17324d
Thank You!
By Rafael L Martins
Introduction to Docker