Docker Hello World Example

Some quick notes on how to get up and running with Docker.


On Fedora this turned out to be pretty easy, simply:

dnf install docker

For other systems see the Docker installation manual.

Start docker demon

systemctl status -l docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2015-12-12 22:40:41 GMT; 3min 35s ago
Main PID: 5818 (docker)
CGroup: /system.slice/docker.service
└─5818 /usr/bin/docker daemon --selinux-enabled

Dec 12 22:40:01 asterix docker[5818]: time="2015-12-12T22:40:01.803909914Z" level=error msg="WARNING: No --storage-opt dm.thinpooldev specified, using loopback; this configuration is strongly discouraged for production use"
Dec 12 22:40:40 asterix docker[5818]: time="2015-12-12T22:40:39.995085846Z" level=warning msg="Docker could not enable SELinux on the host system"
Dec 12 22:40:40 asterix docker[5818]: time="2015-12-12T22:40:40.059743984Z" level=info msg="Option DefaultDriver: bridge"
Dec 12 22:40:40 asterix docker[5818]: time="2015-12-12T22:40:40.059788786Z" level=info msg="Option DefaultNetwork: bridge"
Dec 12 22:40:40 asterix docker[5818]: time="2015-12-12T22:40:40.388329409Z" level=info msg="Firewalld running: true"
Dec 12 22:40:41 asterix docker[5818]: time="2015-12-12T22:40:41.278276562Z" level=info msg="Loading containers: start."
Dec 12 22:40:41 asterix docker[5818]: time="2015-12-12T22:40:41.278585203Z" level=info msg="Loading containers: done."
Dec 12 22:40:41 asterix docker[5818]: time="2015-12-12T22:40:41.278606222Z" level=info msg="Daemon has completed initialization"
Dec 12 22:40:41 asterix docker[5818]: time="2015-12-12T22:40:41.278627443Z" level=info msg="Docker daemon" commit="cb216be/1.8.2" execdriver=native-0.2 graphdriver=devicemapper version=1.8.2-fc22
Dec 12 22:40:41 asterix systemd[1]: Started Docker Application Container Engine.

An interesting warning about no –storage-opt db.thinpooldev specified. This is related to Docker’s storage driver, which the docs explain in good detail.

Run Hello World

First, some info about the docker installation

docker info

It’s better to follow along the official and pretty good step by step documentation on basic docker usage, but the basics are below:

Run a single command

[root@asterix ~]# docker run ubuntu:14.04 /bin/echo 'Hello world'
Hello world

Interactive shell

[root@asterix ~]# docker run -t -i ubuntu:14.04 /bin/bash
root@8aed75e824e2:/# hostname
root@8aed75e824e2:/# exit
[root@asterix ~]#

Restart a container that was previously running

docker ps -a
docker restart $CONTAINER_ID
docker exec -it $CONTAINER_ID /bin/bash

Copy file from container to host


Under the covers

Basic information about the newly created image:

[root@asterix ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE 14.04 d55e68e6cc9c 4 days ago 187.9 MB

Local docker containers are stored in /var/lib/docker

[root@asterix ~]# ls -l /var/lib/docker/
total 36
drwx------ 5 root root 4096 Dec 12 23:09 containers
drwx------ 5 root root 4096 Dec 12 22:50 devicemapper
drwx------ 7 root root 4096 Dec 12 22:50 graph
-rw-r--r-- 1 root root 5120 Dec 12 23:09 linkgraph.db
-rw------- 1 root root 114 Dec 12 22:50 repositories-devicemapper
drwx------ 2 root root 4096 Dec 12 22:50 tmp
drwx------ 2 root root 4096 Dec 12 22:49 trust
drwx------ 2 root root 4096 Dec 12 22:40 volumes

And we can see what looks like a ext4 filesystem:

[root@asterix ~]# file /var/lib/docker/devicemapper/devicemapper/data
/var/lib/docker/devicemapper/devicemapper/data: Linux rev 1.0 ext4 filesystem data, UUID=6d11e0b5-f063-4a4f-99f4-36253b12b297 (extents) (large files) (huge files)
Docker Hello World Example

CentOS 7 kickstart file

The minimal CentOS 7 kickstart file I could come up with for my requirements. Enjoy.

lang en_GB.UTF-8
keyboard uk
timezone UTC
auth  --useshadow  --passalgo=sha512
selinux --disabled
firewall --disabled
services --enabled=NetworkManager,sshd
eula --agreed
rootpw --plaintext password
ignoredisk --only-use=sda
bootloader --location=mbr --timeout=0
clearpart --all --initlabel
part swap --asprimary --fstype="swap" --size=1024
part /boot --fstype xfs --size=200
part pv.01 --size=1 --grow
volgroup rootvg01 pv.01
logvol / --fstype xfs --name=lv01 --vgname=rootvg01 --size=1 --grow

repo --name=base --baseurl=
repo --name=updates --baseurl=
url --url=""

%packages --nobase --ignoremissing

%post --log=/root/postinstall.log

# Do the bare minimum so that I can ssh to the box and run a shell script to execute whatever provisioning needs happening

mkdir -p /root/.ssh
chmod 700 /root/.ssh
echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6hE75Ox6wDfXVJzXeKdyUBO4o19TtGxboJTI2vR3CE9ZJbODIxSr+tfMZcwmuSF892PiahhVzAA2wJ6LdMtFH6FUIGvjU0i7jIo/x+TmvheH46N9qllo2C2ZlxL/HbpRYIyqEntUYcBQzYBvUwnzoDFgS1GhG4LalYp0U9zlHGOA/Wk7qBjH8Ca1mtPSnxudsb/NwERIjfLbvdX9Fc+vkx6fs3ykJv+p8lPEZkw3kcVAfuyhnXzE7kprSHDuOuQo0FDvCTjy9ISxZPvExKT7bD7vQRlrx9PLzYSWI7/evonWHR8c/jPS8U56ii8YH/rtC/iqo4LiwKFxoxaDdS2wD" > /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys

augtool -s <<EOF
#root login needs to be enabled during initial setup so the project specific scripts can be executed
set /files/etc/ssh/sshd_config/PermitRootLogin yes

#This saves time during vm startup
set /files/etc/grub.conf/timeout 0

#Removed because otherwise user install scripts can't use sudo
rm /files/etc/sudoers/Defaults[requiretty]

CentOS 7 kickstart file