Best Way To Install Docker Compose on Rocky Linux 8

In this guide, we want to teach you to Install Docker Compose on Rocky Linux 8. Docker Compose is a tool you can use to define and share multi-container applications. This means you can run a project with multiple containers using a single source.

For example, assume you’re building a project with NodeJS and MongoDB together. You can create a single image that starts both containers as a service – you don’t need to start each separately.

Now follow the guide steps below on the Orcacore website to complete the Docker Compose setup on Rocky Linux 8.

Steps To Install Docker Compose on Rocky Linux 8

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.

Also, you need to have Docker installed on your server. To do this, you can follow this guide on Install and Use Docker on Rocky Linux 8.

Now follow the steps below.

Set up Docker Compose on Rocky Linux 8

First, verify your Docker installation by checking its version:

docker --version
Output
Docker version 23.0.3, build 3e7cbfd

Download Docker Compose Binary

Att his point, you need to visit the GitHub Docker Compose release page and use the curl command to the latest binary package:

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

This will download your Docker compose binary package under /usr/local/bin directory.

Docker Compose File Permission

At this point, you need to set the correct permissions for your Docker compose directory on Rocky Linux 8 with the following command:

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

Verify Docker Compose Installation

Now you can check your Docker compose installation by checking its version:

sudo docker compose version
Verify Docker Compose Installation Rocky Linux 8

How To Use Docker Compose on Rocky Linux 8?

To see that Docker Compose is working correctly, we want to test it with a sample Docker container with Docker compose YML file.

First, create a new directory for setting up the docker-compose file with the command below:

mkdir compose-test

Switch to your directory:

cd compose-test

Then, you need to create a Docker compose YML file file. The compose file is a YML file defining services, networks, and volumes for a Docker container. There are several versions of the compose file format available – 1, 2, 2.x, and 3.x.

From the end of June 2023 Compose V1 won’t be supported anymore and will be removed from all Docker Desktop versions.

To create the Docker compose YML file, you can use the following command or use your favorite text editor, here we use the vi editor:

sudo vi docker-compose.yml

Add the following basic hello-world container based on the latest hello-world image:

version: '2'
services:
   hello-world:
      image:
         hello-world:latest

When you are done, save and close the file.

Next, launch the container within the ‘compose-test’ directory:

sudo docker compose up
Docker compose YML file example

From the output, you should see that your Docker compose is working correctly on Rocky Linux 8.

Uninstall Docker Compose

To uninstall the Docker Compose from your system, first, remove the docker-compose binary package by using the following command:

sudo rm /usr/local/bin/docker-compose

Uninstall the Docker Compose software by running this command:

sudo dnf remove docker-compose

Finally, uninstall all unwanted software dependencies by typing the following command:

sudo dnf autoremove

Conclusion

You can easily run a project with multiple containers using a single source. At this point, you have learned to Install Docker Compose on Rocky Linux 8.

Hope you enjoy it. You may also like these articles:

Install and Configure OpenVPN on Rocky Linux 9

Fix Error Failed to load SELinux policy freezing

Run Binary Files on Linux

Share your love

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!