Installing Docker engine on CentOS 7

Last updated on 06 Sept 2023, 13:10:53.
Category: Cloud servers

CentOS Cloud Servers Docker

Kinamo cloud docker installation centos

This article explains you how to get started with Docker engine on CentOS 7.
The cloud server we will use for this article is an empty, base CentOS 7 cloud server, as you can order at Kinamo. On this machine we will install Docker engine, allowing you to run a docker image (contaner) within docker engine.

We assume you are using a user that can obtain administrative privileges by using "sudo". If you are logged on as root, ommit the "sudo" at the commands below.
Kinamo cloud hosting customers using a cloud server and wish to deploy Docker, preferably use "sudo".

Step 1: upgrade of the operating system

To ensure we have all recent packages - Docker likes to be on an up to date system - we start with a full system upgrade:

$ sudo yum update

The package manager will refresh the package list and see where an upgrade is available. As soon as it is ready it will ask to apply the updates:

Is this ok [y/d/N]:

Choose "y" to continue.

Step 2: adding the Docker repository

As soon as the update is finished, we will add the Docker repository. This allows us to install the latest stable version of the Docker engine.
Since Docker - in terms of technology that is - is relativly new, we suggest to always work with the up to date repository.

With your favorite text editor, create the "docker.repo" file in the "/etc/yum.repos.d" map.

$ sudo vim /etc/yum.repos.d/docker.repo

In this file, copy the following content:

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg

Save the file!
Basically you have added a dockerrepo that points to the official centos docker install files.

Step 3: installation of the Docker engine

Your Docker enabled cloud server is almost ready!
After adding the Docker repository we can install docker-engine with the following command:

$ sudo yum install docker-engine

Yum again will prompt for confirmation. Choose "y" to confirm the installation of docker-engine.

Is this ok [y/d/N]:

Step 4: starting and activating the Docker service

The Docker engine is now installed on the Kinamo cloud server, but let's make sure it is activated and started!

$ sudo systemctl enable docker.service
$ sudo systemctl start docker.service

Step 5: deploying your first Docker image, "Hello World!"

To be sure the installation was successfull we can start the all time classic "hello-world" image:

$ sudo docker run hello-world

You will get the following output:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world

4276590986f6: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:4f32210e234b4ad5cac92efacc0a3d602b02476c754f13d517e1ada048e5a8ba
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

OMG this is great! And now?

Installing Docker engine indeed is a breeze. You're all set to get started with Docker. In real life however working with Docker containers adds many benefits for developers: better seperation of application and the server configuration below, working with several containers on separate cloud servers (for example a split up app web container and a Docker database container with MySQL, just to name a basic example).

Sounds like fun? Try:

sudo docker run -it debian bash

This starts a new terminal session in a new Debian container... on your CentOS server!

This can be tested and verified with:

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 8 (jessie)"
NAME="Debian GNU/Linux"
VERSION_ID="8"
VERSION="8 (jessie)"
ID=debian
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

More images are available at the Docker Hub.

Appendix: an even quicker installation thanks to a Docker install script

Installing Docker can be done even faster... with an install script. This is the ultimate "rapid deployment".

Be warned! You are executing a script straight from the Internet. Be sure to verify the source, otherwise this can harm your system!

Appendix step 1: updating the operating system

We will start with a complete operating system upgrade:
$ sudo yum update

Appendix step 2: executing the docker install script

Next step is to execute the installation script:
$ curl -fsSL https://get.docker.com/ | sh

Appendix step 3: starting and activating the docker engine service

The Docker engine is now installed, but let's be sure it is activated and started.
$ systemctl enable docker.service
$ systemctl start docker.service

Appendix step 4: Hello World, again!

To test if our Docker installation was successfull, we can start the "hello-world" image.

$ sudo docker run hello-world

Conclusion

Docker hosting in Belgium is near! A Kinamo cloud server allows you to get creative! In a next article we will go beyond the "Hello World!" stuff and we will deploy some real use web magic.


Related articles

Hoe de taal van Kinamo webmail aanpassen

Dit FAQ-artikel legt uit hoe je de taal van de gebruikersinterface kunt aanpassen in Kinamo Webmail

Read more

Can I read my e-mail online (through webmail)?

Each Kinamo e-mail address can be checked through an extensive webmail e-mail client. The only thing you need are an...

Read more

Create an automatic SPAM filter in the Kinamo Webmail

Do you have an email with Kinamo? Discover here how to create a special filter via Kinamo Webmail to keep...

Read more

Need extra help?

Were not all your questions answered?
Don't worry, we will be happy to help you via a support request!

Kinamo

Select your language

All languages: