Installing Docker on CentOS 8

Docker is a system for managing containers, which has become very popular in recent years. The main advantage of Docker to the developer that he once is enough to configure the containers in his car, and then he will be able to transfer the program to any server whether it is Linux or Windows and there will be all work, you just have to be installed Docker.

The application runs in an LXC container in which you installed the Linux distribution and set of software programs needed to run the application. Such containers may be multiple and they can interact with each other over the network. In this article we will look how to install Docker in CentOS 8. The procedure is almost the same as in CentOS 7, but because of the transition distribution for nftables there are some differences.

Installing Docker CeontOS 8

To get the latest version of the program, you must first add an official Docker repository to the system:

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

Then install Docker CentOS 8 is performed with the command:

dnf install docker-ce

These commands will be relevant for both Fedora and CentOS 7 only for the latter will need to change the package Manager to yum and the repository will be added differently.

Then start the Docker service and add it to the startup:

systemctl start docker

systemctl enable docker

systemctl status docker

Since CentOS 8 has moved to a new subsystem of the firewall nftables, and Docker only supports iptables, the network inside the container will not work. To fix this we need to enable masquerading traffic through the firewall:

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

Then restart the firewall to active rules has been updated:

firewall-cmd --reload

Installing Docker Compose

Docker is typically installed with the tool automatic deployment and configuration of containers in docker-compose. This is a utility that will help take your project to another machine with a single command. To install it run:

wget "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname-s)$(uname -m)" 

mv ./docker-compose /usr/local/bin/docker-compose

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

Ready to install docker compose CentOS 8 is finished and you can start working with this tool.

Check the operation of the Docker

To make sure Docker is installed and running you can see his version:

docker --version

And you can run the Hello world container:

docker run hello-world

Can also see the version of docker-compose:

docker-compose --version

Remove Docker in CentOS

Remove Docker CentOS by simply deleting the package that you previously installed, to do this, run:

dnf remove docker-ce

To remove docker-compose simply delete the file /usr/local/bin/docker-compose, this utility is only there and its not anywhere else in the system.

Insights

In this article we discussed how to install docker CentOS 8 and solve the network problem in containers. Write in the comments whether you want a continuation of this theme in articles on how to use Docker and Docker compose to deploy their applications.

Source: losst.ru

(Visited 3 times, 1 visits today)