Docker
Back to current versionRestore this version

Docker#

Install with apt-get install docker.io. Beware that you need a 64bit version OS !

Then simply start a container with :

docker run -i -t ubuntu /bin/bash

This starts a container in interactive mode. The first time you run this, the image is downloaded from docker hub and stored locally.
When you exit the container, it is immediately "gone" too.

With docker ps you can see what is running:

root@athena:~# docker ps
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS               NAMES
9539bc7b78df        ubuntu-14.04:latest   /bin/bash           6 seconds ago       Up 5 seconds                            silly_darwin    

Now, the funny thing is, you can do something in the container, like installing vim or openjdk-7-jdk, and then commit that (from outside the container) :

root@athena:~# docker commit -m "added java" -a "Harry Metske" e5acc9ff7c9c  ubuntu-14.04
feb996bac7c44edd0cfe28b54901f2ff500b4c18fed203931b703d14cc89b8c0

And after that you can see the results with docker images :

root@athena:~# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu-14.04        latest              feb996bac7c4        12 seconds ago      664.2 MB
ubuntu/1404         v1.0                9e7a0bc71946        42 minutes ago      311.2 MB
ubuntu              latest              5506de2b643b        6 days ago          199.3 MB

After that you can run that new container again (and have java installed) :

 docker run -h hostje -i -t --user=metskem feb996bac7c4

You can also list the history of images:

root@athena:~# docker history feb996bac7c4
IMAGE               CREATED             CREATED BY                                      SIZE
feb996bac7c4        41 minutes ago      /bin/bash                                       353 MB
9e7a0bc71946        About an hour ago   /bin/bash                                       112 MB
5506de2b643b        6 days ago          /bin/sh -c #(nop) CMD [/bin/bash]               0 B
22093c35d77b        6 days ago          /bin/sh -c apt-get update && apt-get dist-upg   6.558 MB
3680052c0f5c        6 days ago          /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$/   1.895 kB
e791be0477f2        6 days ago          /bin/sh -c rm -rf /var/lib/apt/lists/*          0 B
ccb62158e970        6 days ago          /bin/sh -c echo '#!/bin/sh' > /usr/sbin/polic   194.8 kB
d497ad3926c8        9 days ago          /bin/sh -c #(nop) ADD file:3996e886f2aa934dda   192.5 MB
511136ea3c5a        16 months ago                                                       0 B

Note that no daemons are started after starting the container. For example, installing openssh-server (and update-rc.d defaults) it is not started after running the container ==> find out, there must be other options