by
Marek Goldmann
04.11.2013
A project to create and manage containers.
Yes, a lightweight operating system virtualization.
It's completely different.
Virtual Machine (KVM, VMware) | Container (LXC, OpenVZ) | |
---|---|---|
Hardware | Simulated | Uses it (almost) directly |
Supported OS'es | Almost any | Only Linux |
Space | User space | Kernel space |
Separation | Full | Control Groups (cgroups) |
Startup time | Seconds to minutes | Miliseconds |
Scalability | A few | Sky is the limit (thousands) |
Custom kernel | Yes | No |
Enterprise features (live migration, etc) | Yes | No |
Ease of creation | Moderate | Easy |
Time consumption of creation | High | Low |
Size | HUGE | Small |
dotCloud* and a powerful community.
* dotCloud, Inc. was recently renamed to Docker, Inc.
Achieved after 10 months since first commit to GitHub
Running, stopping, attaching, etc... containers
Creating images
Storage for images
It's simple! Use Dockerfiles.
A plain text file with instructions that automate building the image.
# Base on the Fedora 20 image
FROM mattdm/fedora
# Upgrade the image
RUN yum -y update
# Install java
RUN yum -y install java-1.7.0-openjdk-devel wget
# Get WildFly
RUN wget http://download.jboss.org/wildfly/8.0.0.Beta1/wildfly-8.0.0.Beta1.tar.gz -O /opt/wildfly.tar.gz
RUN tar -xf /opt/wildfly.tar.gz -C /opt
# Run WildFly after container boot
ENTRYPOINT /opt/wildfly-8.0.0.Beta1/bin/standalone.sh -c standalone-ha.xml -b 0.0.0.0
This should be saved as Dockerfile
FROM
: the image we're basing on / extendingRUN
: The command to execute at the build timeENTRYPOINT
: The command to be executed after the container bootBut there is a lot more!
docker build .
$ docker build .
Uploading context 10240 bytes
Step 1 : FROM mattdm/fedora
[SNIP]
Step 4 : RUN wget -q http://download.jboss.org/wildfly/8.0.0.Beta1/wildfly-8.0.0.Beta1.tar.gz -O /opt/wildfly.tar.gz
---> Running in 41467b97b423
---> 112766c23202
Step 5 : RUN tar -xf /opt/wildfly.tar.gz -C /opt
---> Running in d07d0c5c3dab
---> c53f9f4ceb1e
Step 6 : ENTRYPOINT /opt/wildfly-8.0.0.Beta1/bin/standalone.sh -c standalone-ha.xml -b 0.0.0.0
---> Running in a9b2cecf4db5
---> 5894688e4f2e
Successfully built 5894688e4f2e
We've built image 5894688e4f2e
Dockerfile
build
command once again
$ time docker build .
Uploading context 10240 bytes
Step 1 : FROM mattdm/fedora
---> 0f3e92b4e94d
[SNIP]
Step 4 : RUN wget -q http://download.jboss.org/wildfly/8.0.0.Beta1/wildfly-8.0.0.Beta1.tar.gz -O /opt/wildfly.tar.gz
---> Using cache
---> 2ad6655478dd
Step 5 : RUN tar -xf /opt/wildfly.tar.gz -C /opt
---> Using cache
---> c0f63f06e9ec
Step 6 : RUN touch /etc/something
---> Running in 8426dd5570af
---> 7ef016a00cde
Step 7 : ENTRYPOINT /opt/wildfly-8.0.0.Beta1/bin/standalone.sh -c standalone-ha.xml -b 0.0.0.0
---> Running in 60bfa9d3a746
---> e757e0ea05d7
Successfully built e757e0ea05d7
real 0m0.307s
user 0m0.000s
sys 0m0.018s
We've built a new image e757e0ea05d7
Yes, 300ms!
$ docker images
REPOSITORY TAG ID CREATED SIZE
<none> <none> e757e0ea05d7 37 minutes ago 12.29 kB (virtual 1.056 GB)
<none> <none> 5894688e4f2e 46 minutes ago 12.29 kB (virtual 1.056 GB)
Yes, 12.29kB!
docker pull
Pull image or repository to the registry
docker push
Push image from registry to a repository
docker run
Run a command in a new container based on the specified image
docker stop
Stop a container
docker start
Start a stopped container
docker rm
Remove a stopped container
docker rmi
Remove an image from registry
It's (fairly) easy to create a PaaS with Docker
There is even a tutorial to create one in 5 minutes...
Build once - run anywhere!
Attributions: