Install Docker and Docker compose on RockyLinux 8
Docker is an open-source containerization tool used to simplify the creation and deployment of applications by using the concept of containers. Containers allow us to package all the parts of an application and deploy it as one entity.Docker-compose is a Docker tool used to define and run multi-container applications. With Compose, you use a YAML file to configure your application’s services and create all the app’s services from that configuration.
In this Article,we will show you how to install docker and docker compose on Rocky Linux8 system.
Step 1 : install updates
we will install all the available updates using dnf
sudo dnf update
Also Read -> How to Install Docker on Ubuntu 20 04
step 2: Install docker
First we Add official Docker CE repository on your Rocky Linux 8. so that we can install latest and stable version of docker.
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
then install docker with the following command.
sudo dnf install docker-ce
sample output:
Docker CE Stable - x86_64 289 B/s | 15 kB 00:52
Last metadata expiration check: 0:00:01 ago on Thu 16 Sep 2021 05:20:41 PM IST.
Dependencies resolved.
========================================================================================================================================================================
Package Architecture Version Repository Size
========================================================================================================================================================================
Installing:
docker-ce x86_64 3:20.10.8-3.el8 docker-ce-stable 22 M
Installing dependencies:
checkpolicy x86_64 2.9-1.el8 baseos 345 k
container-selinux noarch 2:2.164.1-1.module+el8.4.0+643+525e162a appstream 51 k
containerd.io x86_64 1.4.9-3.1.el8 docker-ce-stable 30 M
docker-ce-cli x86_64 1:20.10.8-3.el8 docker-ce-stable 29 M
docker-ce-rootless-extras x86_64 20.10.8-3.el8 docker-ce-stable 4.6 M
docker-scan-plugin x86_64 0.8.0-3.el8 docker-ce-stable 4.2 M
fuse-common x86_64 3.2.1-12.el8 baseos 20 k
fuse-overlayfs x86_64 1.6-1.module+el8.4.0+643+525e162a appstream 72 k
fuse3 x86_64 3.2.1-12.el8 baseos 49 k
fuse3-libs x86_64 3.2.1-12.el8 baseos 93 k
libcgroup x86_64 0.41-19.el8 baseos 69 k
libslirp x86_64 4.3.1-1.module+el8.4.0+556+40122d08 appstream 68 k
policycoreutils-python-utils noarch 2.9-14.el8 baseos 251 k
python3-audit x86_64 3.0-0.17.20191104git1c2f876.el8.1 baseos 85 k
python3-libsemanage x86_64 2.9-6.el8 baseos 126 k
python3-policycoreutils noarch 2.9-14.el8 baseos 2.2 M
python3-setools x86_64 4.3.0-2.el8 baseos 625 k
slirp4netns x86_64 1.1.8-1.module+el8.4.0+556+40122d08 appstream 50 k
Enabling module streams:
container-tools rhel8
Transaction Summary
========================================================================================================================================================================
Install 19 Packages
Total download size: 94 M
Installed size: 387 M
Is this ok [y/N]: y
once docker is installed, start and enable and check the status of docker service using below commands.
sudo systemctl start docker
sudo systemctl enable docker
sudo systemctl status docker
output:
[root@RockyLinux ~]#systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-09-16 17:49:28 IST; 49s ago
Docs: https://docs.docker.com
Main PID: 18605 (dockerd)
you can verify docker version with the following command.
docker --version
sample output:
Docker version 20.10.8, build 3967b7d
Step 3: Add local user to docker group
Add your current system user into the Docker group so that you can easily run the docker commands without using sudo.
sudo usermod -aG docker $USER
Also Read -> How to Install Docker on Debian 10
you can replace $USER in the above command with the specific system’s user you want to give the rights to manage Docker.
Step 4: Testing Docker
To test docker installation, run below command.
docker run hello-world
sample output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete
Digest: sha256:61bd3cb6014296e214ff4c6407a5a7e7092dfa8eefdbbec539e133e97f63e09f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
Step 5: Install docker compose
you can download the current stable release of Docker Compose using curl.
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
if you want diffrent version, you can find them on github Repository page.
once it is downloaded, execute the next permissions to the binary with the following command.
sudo chmod +x /usr/local/bin/docker-compose
if you want to run docker-compose from /usr/bin path then create symbolic link
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
Now verify the version
docker-compose --version
sample output:
docker-compose version 1.29.2, build 5becea4c
That's it. Now you have successfully installed docker and docker compose on Rocky Linux 8 system.
Also Read -> How to Install Docker on Centos 7