Docker is a new virtualization solution based on any kernel 3.10 Linux machine.

Start from a CentOS virtual machine :

  • CentOS 7.2 :
[root@docker ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
  • Built on kernel 3.10 :
[root@docker ~]# uname -sr
Linux 3.10.0-327.3.1.el7.x86_64

Install “docker” :

[root@docker ~]# yum -y install docker docker-registry

Here is the “docker” version :

[root@docker ~]# docker --version
Docker version 1.8.2-el7.centos, build a01dc02/1.8.2

Start “docker” service :

[root@docker ~]# systemctl start docker

And across reboot :

[root@docker ~]# systemctl enable docker
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/docker.service.

See the status :

[root@docker ~]# 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 Thu 2016-01-14 17:39:23 CET; 1min 3s ago
 Main PID: 10456 (docker)
   CGroup: /system.slice/docker.service
           └─10456 /usr/bin/docker daemon --selinux-enabled

Jan 14 17:39:21 docker docker[10456]: time="2016-01-14T17:39:21.972418994+01:00" level=info msg="[graphdriver] using prior storage driver \"devicemapper\""
Jan 14 17:39:22 docker docker[10456]: time="2016-01-14T17:39:22.158229708+01:00" level=info msg="Option DefaultDriver: bridge"
Jan 14 17:39:22 docker docker[10456]: time="2016-01-14T17:39:22.158290877+01:00" level=info msg="Option DefaultNetwork: bridge"
Jan 14 17:39:22 docker docker[10456]: time="2016-01-14T17:39:22.859228257+01:00" level=warning msg="Running modprobe bridge nf_nat br_netfilter failed with message: modprobe: WARNING: Module br_netfilter not found.\n, error: exit status 1"
Jan 14 17:39:22 docker docker[10456]: time="2016-01-14T17:39:22.939999470+01:00" level=info msg="Firewalld running: true"
Jan 14 17:39:23 docker docker[10456]: time="2016-01-14T17:39:23.893386078+01:00" level=info msg="Loading containers: start."
Jan 14 17:39:23 docker docker[10456]: time="2016-01-14T17:39:23.893721869+01:00" level=info msg="Loading containers: done."
Jan 14 17:39:23 docker docker[10456]: time="2016-01-14T17:39:23.893752472+01:00" level=info msg="Daemon has completed initialization"
Jan 14 17:39:23 docker docker[10456]: time="2016-01-14T17:39:23.893780510+01:00" level=info msg="Docker daemon" commit="a01dc02/1.8.2" execdriver=native-0.2 graphdriver=devicemapper version=1.8.2-el7.centos
Jan 14 17:39:23 docker systemd[1]: Started Docker Application Container Engine.

Docker images

Currently, we have no images installed :

[root@docker ~]# docker images -a

Looking for existing image (Ubuntu for example) we can download (only 25 results are displayed) ?

[root@docker ~]# docker search ubuntu
INDEX      NAME                                     DESCRIPTION                                   STARS OFFICIAL AUTOMATED                          Ubuntu is a Debian-based Linux operating s... 2915  [OK]                  Upstart is an event-based replacement for ...   57  [OK]  Ubuntu with openssh-server and NoVNC on po...   30           [OK]        Always updated official Ubuntu docker imag...   25           [OK]              debootstrap --variant=minbase --components...   21  [OK]         Ubuntu 14.04 with CUDA drivers pre-installed    18           [OK]                     NeuroDebian provides neuroscience research...   15  [OK]          Dockerized SSH service, built on top of of...   15           [OK]                                                                 5           [OK]                 Simple always updated Ubuntu docker images...    4           [OK]                   This is a docker images different LTS vers...    3           [OK]                Docker base image built on Ubuntu with Sup...    2           [OK] LAMP on Ubuntu with wp-cli installed             2           [OK]         Ubuntu Linuxの日本語remix風味です                 1           [OK]              This is just a small and clean base Ubuntu...    1           [OK]           LAMP server on Ubuntu                            1           [OK]           Ubuntu image provided by seetheprogress us...    1           [OK]           Ubuntu 15.10 root docker images with commo...    1           [OK]                   Ubuntu 14.04 LTS (Trusty Tahr)                   0           [OK]                   Ubuntu LTS                                       0           [OK]             Ubuntu base image                                0           [OK]                  Ubuntu with the needful                          0           [OK]                 TeamRock's Ubuntu image configured with AW...    0           [OK]                Docker images for ubuntu                         0           [OK]                                                                      0           [OK]

Open a web browser on  Docker Hub, then search “Ubuntu” :













Download Ubuntu “official” image :

[root@docker ~]# docker pull ubuntu
Using default tag: latest
Trying to pull repository ... latest: Pulling from library/ubuntu
895b070402bd: Pull complete
02e5bca4149b: Pull complete
b2ae0a712b39: Pull complete
af88597ec24b: Pull complete
library/ubuntu:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:b53bb7b0d18842214ac7472c2a8801e8682c247d30f1ba4bab0083a2e2e091ea
Status: Downloaded newer image for

So, now we have those images :

[root@docker ~]# docker images -a
REPOSITORY       TAG    IMAGE ID     CREATED     VIRTUAL SIZE latest af88597ec24b 10 days ago 187.9 MB
<none>           <none> b2ae0a712b39 10 days ago 187.9 MB
<none>           <none> 02e5bca4149b 10 days ago 187.9 MB
<none>           <none> 895b070402bd 10 days ago 187.7 MB

My first container

Create your first container :

[root@docker ~]# docker run -t -i -d ubuntu

Where :

  • -t : Allocate a pseudo-TTY
  • -i : Keep STDIN open even if not attached
  • -d : Run container in background and print container ID

This container is now running :

[root@docker ~]# docker ps -a
ba33baf11d62  ubuntu  "/bin/bash"  4 minutes ago  Up 4 minutes         furious_cori

To logon to this container :

[root@docker ~]# docker exec -t -i furious_cori bash
root@ba33baf11d62:/# id
uid=0(root) gid=0(root) groups=0(root)
root@ba33baf11d62:/# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.3 LTS
Release: 14.04
Codename: trusty
root@ba33baf11d62:/# exit

Stop this container :

[root@docker ~]# docker stop furious_cori

This container is still there, but not running anymore :

[root@docker ~]# docker ps -a
ba33baf11d62 ubuntu "/bin/bash" 24 minutes ago Exited (0) About a minute ago       furious_cori

To remove it :

[root@docker ~]# docker rm furious_cori

How to run several Linux containers on the same docker machine ?

We saw on Docker Hub :

Supported tags and respective Dockerfile links

12.04.5, 12.04, precise-20151208, precise (precise/Dockerfile)
14.04.3, 14.04, trusty-20151218, trusty, latest (trusty/Dockerfile)
15.04, vivid-20151208, vivid (vivid/Dockerfile)
15.10, wily-20151208, wily (wily/Dockerfile)
16.04, xenial-20151218.1, xenial (xenial/Dockerfile)

Install fedora ;

[root@docker ~]# docker pull fedora
[root@docker ~]# docker pull centos

We have now those images :

[root@docker ~]# docker images
REPOSITORY       TAG    IMAGE ID     CREATED     VIRTUAL SIZE latest 0721f2b3cb16 10 days ago 206.3 MB latest af88597ec24b 10 days ago 187.9 MB latest 60e65a8e4030 3 weeks ago 196.6 MB

Create and run a fedora container :

[root@docker ~]# docker run -t -i -d --name fedora fedora /bin/bash

Create and run a CentOS container :

[root@docker ~]# docker run -t -i -d --name CentOS centos /bin/bash

We have now 2 containers running :

[root@docker ~]# docker ps
ebae479717ac centos "/bin/bash" 31 seconds ago Up 30 seconds       CentOS
3182473dc136 fedora "/bin/bash" 2 minutes ago  Up 2 minutes        fedora

Logon to the “CentOS” container :

[root@docker ~]# docker exec -t -i CentOS bash
[root@ebae479717ac /]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@ebae479717ac /]# exit

Logon to the “fedora container” :

[root@docker ~]# docker exec -t -i fedora bash
[root@3182473dc136 /]# cat /etc/redhat-release
Fedora release 23 (Twenty Three)
[root@3182473dc136 /]# exit
exit    Send article as PDF   

Leave a Reply

Your email address will not be published. Required fields are marked *