Last update: 2019-11-09

Using Docker on CentOS 7

CentOS 7 is a great distribution of Linux for servers and development systems. With micro-services, one potentially useful tool you may want to use is Docker containers, however this doesn't come built-in on CentOS. This short tutorial will show you how to install Docker and use common comments.

Adding the Docker repository

The first thing to do is to add the Docker repository with this command:

yum install yum-utils
yum-config-manager --add-repo

Installing Docker

Next you can install the Docker Community Edition from the repo:

yum install docker-ce

Note that if you get a conflict with the older version of Docker which is present on the CentOS extras repository, you may need to uninstall that first, along with doing software updates:

yum update
yum remove docker docker-common

Once installed, you can start and enable the daemon:

systemctl start docker
systemctl enable docker

Finally, check the version installed:

docker version

Listing images

You can get a list of images with this command:

docker image ls

Note that you need to setup a registry (either public or private) such as from which you can pull or push images. You can then login to the hub from the command line:

docker login

Also note that if you're behind a web proxy you need to do the following steps:

mkdir /etc/systemd/system/docker.service.d
nano /etc/systemd/system/docker.service.d/http-proxy.conf

And put this content in the file:

Environment="HTTPS_PROXY=" "NO_PROXY=localhost,centos,*"

Looking to expand into the cloud? See what a certified freelancer can do for you.

© 2007-2019 Patrick Lambert - All resources on this site are provided under the MIT License - You can contact me at: