RHEL7: How to get started with Docker.

Share this link

Presentation of Docker

Docker is a platform for developers and sysadmins to develop, ship, and run applications.

Docker allows you to create lightweight, portable, self-sufficient containers from any application and lets you get your code tested and deployed into production as fast as possible.


To install Docker, type:

# yum install -y docker

Until recently, Red Hat advised to stop the firewalld service because there was some incompatibility with Docker. To disable the firewalld service, type:

# systemctl disable firewalld && systemctl stop firewalld

Note: According to this bug report, this shouldn’t be necessary any more.

To enable and start Docker, type:

# systemctl enable docker && systemctl start docker

To get the installed version of Docker, type:

# docker version
Client version: 1.2.0
Client API version: 1.14
Go version (client): go1.3.3
Git commit (client): 2a2f26c/1.2.0
OS/Arch (client): linux/amd64
Server version: 1.2.0
Server API version: 1.14
Go version (server): go1.3.3
Git commit (server): 2a2f26c/1.2.0

To get some additional information, type:

# docker info
Containers: 1
Images: 3
Storage Driver: devicemapper
Pool Name: docker-253:0-31125-pool
Pool Blocksize: 64 Kb
Data file: /var/lib/docker/devicemapper/devicemapper/data
Metadata file: /var/lib/docker/devicemapper/devicemapper/metadata
Data Space Used: 557.4 Mb
Data Space Total: 102400.0 Mb
Metadata Space Used: 0.9 Mb
Metadata Space Total: 2048.0 Mb
Execution Driver: native-0.2
Kernel Version: 3.10.0-123.9.3.el7.x86_64
Operating System: CentOS Linux 7 (Core)

Docker Image Download

If you’ve got 1GB of free disk space on the / partition, to install a CentOS 7 distribution, type:

# docker pull centos:centos7
Pulling repository centos
ae0c2d0bdc10: Download complete
511136ea3c5a: Download complete
5b12ef8fd570: Download complete

Note: If you specify centos instead of centos:centos7, you will get centos5, centos6, centos7 and latest (equals to centos7) images. Be prepared to allow 2GB of free disk space.

To display the list of locally available images, type:

# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
centos              centos7             ae0c2d0bdc10        2 weeks ago         224 MB

Note: To remove this image, type # docker rmi ae0c2d0bdc10 or # docker rmi centos:centos7.

To test your new image, type:

# docker run centos:centos7 /bin/ping google.com -c 2
PING google.com ( 56(84) bytes of data.
64 bytes from par10s10-in-f8.1e100.net ( icmp_seq=1 ttl=54 time=12.5 ms
64 bytes from par10s10-in-f8.1e100.net ( icmp_seq=2 ttl=54 time=12.6 ms

Container Creation

We are going to create a container (here called python_web) running a web server in Python on the 8000 port (/bin/python -m SimpleHTTPServer 8000).

This example is taken from a Red Hat article about Docker.

# mkdir -p /var/www/html
# echo "Server up and running" > /var/www/html/test.txt
# restorecon -R /var/www
# docker run -d -p 8000:8000 --name="python_web" -v /usr/sbin:/usr/sbin -v /usr/bin:/usr/bin \
-v /usr/lib64:/usr/lib64 -w /var/www/html -v /var/www/html:/var/www/html centos:centos7 \
/bin/python -m SimpleHTTPServer 8000
# netstat -tupln | grep 8000
tcp6       0      0 :::8000                 :::*            LISTEN      27739/docker
# curl localhost:8000/test.txt
Server up and running

Sources: Docker web site and Red Hat’s article about Docker.

Additional Resources

You can also:

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

Leave a Reply

Be the First to Comment!

Notify of


RHCSA7: Task of the day

Allowed time: 5 minutes.
Add 100MB of swap space to the machine using a new logical volume.

RHCE7: Task of the day

Allowed time: 10 minutes.
Set up a default secure MariaDB database called maria and create a table named people with two columns respectively name varchar(20) and age int(10) unsigned.

Poll for favorite RHEL 7 book

What is your favorite RHEL 7 book to prepare RHCSA & RHCE exams?

View Results

Loading ... Loading ...

Poll for most difficult RHCSA 7 topic

What do you think is the most difficult RHCSA 7 topic?

View Results

Loading ... Loading ...

Poll for most difficult RHCE 7 topic

What do you think is the most difficult RHCE 7 topic?

View Results

Loading ... Loading ...