Docker and Docker Compose Installation on Rocky Linux 8

Docker is a free and open platform for building, delivering, and operating apps. Docker allows you to decouple your apps from your infrastructure, allowing you to fastly release software. You can manage your infrastructure the same way you control your applications with Docker. You may drastically minimize the time between writing code and executing it in production by leveraging Docker’s approaches for shipping, testing, and deploying code quickly.

Docker Compose is a Docker application that allows you to define and operate multi-container Docker applications. You configure your application’s services using Compose using a YAML file. Then you build and start all of the services from your setup with a single command.

In this article, we are going to learn how to install docker and docker-compose with examples and commands.

Update the system

The system is updated with the latest packages using the dnf update command.

[rocky@server1 ~]$ sudo dnf update -y

You may also reboot the system by simply writing the reboot command.

[rocky@server1 ~]$ reboot

Configure and install Docker

For the installation of docker, we need to configure the official packages repository. To configure and add the repository dnf config command is used.

[rocky@server1 ~]$ sudo dnf config-manager --add-repo=https://download.docker.com /linux/centos/docker-ce.repo

Configure Docker repository

After the configuration and adding the repo for the docker, the docker is installed using the following command.

[rocky@server1 ~]$ sudo dnf install -y docker-ce

If any error is occurred during the installation process, than run the following command again to install docker.

[rocky@server1 ~]$ sudo dnf install docker-ce --allowerassing -y

Docker services

To start and enable the service of docker manually the command is given below.

[rocky@server1 ~]$ sudo systemctl start docker
[rocky@server1 ~]$ sudo systemctl enable docker

Start Docker

To check the status of the docker service following command is used.

[rocky@server1 ~]$ sudo systemctl status docker

Docker is active

Finally, the command to check the version of the docker.

[rocky@server1 ~]$ docker --verison

Docker testing

After the installation and the enable process, check whether the docker is running by typing the following command.

[rocky@server1 ~]$ docker run hello-world

Test Docker

The above result verifies that the container ‘hello-world’ was successfully launched, as well as the installation of Docker.

Docker-Compose Installation

Docker Compose is a tool that was created to assist in the definition and sharing of multi-container applications. With Compose, we can specify the services in a YAML file and then spin everything up or down with a single command.

Use the curl command to transfer data from the github and proceed to install the docker-compose. First, install the curl using the dnf command.

[rocky@server1 ~]$ sudo dnf install -y curl

Now, use the curl command to transfer the docker compose data from GitHub to the local machine.

[rocky@server1 ~]$ sudo curl -L "https://github.com/docker/compose/releases/download/ 1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

Install Docker Compose

Here, execute permission is given to the docker-compose using the chmod command.

[rocky@server1 ~]$ sudo chmod +x /user/local/bin/docker-compose

Finally, check the version of the docker-compose using the following command.

[rocky@server1 ~]$ sudo docker-compose -- version

Conclusion

The above example and command are for the installation of docker and docker-compose on Rocky Linux. Thank you for checking it out!!