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:

<bash>
yum install yum-utils
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Installing Docker

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

<bash>
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:

<bash>
yum update
yum remove docker docker-common

Once installed, you can start and enable the daemon:

<bash>
systemctl start docker
systemctl enable docker

Finally, check the version installed:

<bash>
docker version

Listing images

You can get a list of images with this command:

<bash>
docker image ls

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

<bash>
docker login

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

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

And put this content in the file:

[Service]
Environment="HTTPS_PROXY=http://proxy.your-domain.com:8000/" "NO_PROXY=localhost,centos,*.your-domain.com"

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: contact@dendory.net