News
Seven days of Black Friday madness — great deal from Serverspace!
Serverspace Black Friday
JH
Joe Harris
December 28, 2020
Updated June 7, 2023

How to Install Docker and Docker compose on CentOS 8

CentOS Docker FAQ Linux

Using another OS?

Select the desired version or distribution.

Docker is a container management system. The Linux distribution and the necessary applications for the software being developed are deployed inside the container. Once configured, the container can be moved to any operating system where docker is installed, and work there without any additional steps. This is the reason for the popularity of Docker among developers and DevOps.

In the Serverspace you can create a server with already installed app "Docker".

In this tutorial, we will install Docker, Docker compose, and run a test container.

Docker installation on CentOS 8

To install and always update Docker to the latest version, add the developer repository to the system.

dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Install the Docker package.

dnf install docker-ce docker-ce-cli containerd.io

Start the Docker service and add it to autorun.

systemctl enable --now docker

CentOS 8 uses a firewall other than Docker. Hence, if you have firewalld enabled, you need to add a masquerade rule to it.

firewall-cmd --zone=public --add-masquerade --permanent
firewall-cmd --reload

Docker compose installation

Docker is often installed along with Docker compose. It is this utility that allows you to deploy your project to another machine using one command. To download it, run the following command:

curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Make it executable.

chmod +x /usr/local/bin/docker-compose

Using Docker as a non-root user

To be able to use Docker as a non-root user, you must add that user to the docker group.

usermod -aG docker username

Replace the username with the desired user name. After executing this command, he will need to log out from the system and log in again.

Be careful! Users of this group can take control of the Docker host.

Docker test container running

You can verify that Docker is working properly by running a test container.

docker run hello-world

As a result of executing the command, you should see a message that everything is working well.

Vote:
3 out of 5
Аverage rating : 3.6
Rated by: 7
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300
We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.