Hi hope you are doing well, lets learn about “How to Setup and Install Docker and Docker Compose on Rocky Linux 8”, the Docker is the fastest growing technology in the IT market.
Many industries are moving towards docker from the normal EC2 instances. Docker is the container technology.
It is PAAS (Platform as a Service), which uses a OS virtualisation to deliver software in packages called containers.
The containers are the bundle of the packages, library files, and some configuration files. It was first started in 2013 and developed by Docker, Inc.
We will also look into the docker compose, in this post. Docker compose is used to run the multiple containers, with the same configuration.
So we will make a YAML file and run the same with the docker compose command.
So lets have the Setup of Docker CE on Rocky Linux 8 Step by Step Guide.
Setup and Install Docker CE on Rocky Linux 8
STEP 1: Update the Repository for the Docker to setup and Install on Rocky Linux 8.
So firstly we will update the repository and update the repo with the dnf command.
$ sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
So the above command will add the repo for Docker into Rocky linux 8.
$ sudo dnf update
dnf update command will update the repository, you might get the error while updating the repositories for dependencies or the conflicts error.
STEP 2: Setup and Install Docker CE on Rocky Linux 8 via dnf command.
So, if the update was properly done then use “dnf install”, else use with the –allowerasing parameter.
$ sudo dnf install -y docker-ce docker-ce-cli containerd.io
If you will get the error while update then use below command
$ sudo dnf install docker-ce docker-ce-cli containerd.io --allowerasing -y
Once the docker installation get’s completed , start the services for the docker and enable it after rebooting the System.
$ sudo systemctl start docker.service
$ sudo systemctl status docker.service
So we have check the status for docker, and it is active running on the Rocky linux 8, so enable the service for docker at the time of booting.
$ sudo systemctl enable docker.service
STEP 3: Add the User in Docker Group.
Now lets add user “tastethelinux” into the docker group.
sudo usermod -aG docker $USER
“$USER” is the username tastethelinux, you can use whoami to check the username.
docker --version OUTPUT: Docker version 20.10.8, build 3967b7d
So then check version using docker command without sudo, you will get the version for the docker.
So we have successfully install docker ce on Rocky Linux 8, lets create a Container for the MongoDB.
STEP 4: Test Docker by Pulling Images.
So here we will create a container for MongoDB on docker, let’s use the pull command to pull the MongoDB image first.
$ docker pull mongo
So we have pulled the images for mongo from the docker, Once it’s completed you can check the image by using “docker images”.
$ docker images
STEP 5: Run Docker Container in Rocky Linux 8.
Now let’s run the docker container by using docker run command.
$ docker run -d mongo
So we have successfully run the docker container in Rocky Linux 8 for MongoDB, now if we have to verify the container is running or not use “docker ps” command.
$ docker ps
So we have install Docker CE in Rocky Linux 8, then run the container for MongoDB server on Rocky Linux 8.
Setup and Install Docker Compose on Rocky Linux 8.
Let’s install Docker Compose on Rocky Linux 8, with the curl command.
$ 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
So, the above command will install docker compose in “/usr/local/bin” directory, now give the executable permission to the “docker-compose” script.
$ sudo chmod +x /usr/local/bin/docker-compose
Now lets create soft link for “docker-compose”, and check the docker compose version.
$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
$ docker-compose –version
docker-compose version 1.29.2, build 5becea4c
So we have successfully installed docker compose on Rocky Linux 8, and also checked the version for docker compose command.
If you want to install MongoDB on EC2 instances follow the link. Thanks to Read the article. Keep Supporting US.
One Reply to “Install Docker and Docker Compose on Rocky Linux 8.”