Linux

Install Docker and Docker Compose on CentOS

Docker on Centos

Steps to Install Docker and Docker Compose on CentOS:

Install yum-utils:

Bash
sudo yum install -y yum-utils

The yum-utils package includes a collection of tools for managing YUM repositories and packages more efficiently.

Add Docker Repository:

Bash
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

This command adds the official Docker CE (Community Edition) repository to your system so you can install Docker from it.

Install Docker:

Bash
sudo yum install docker-ce docker-ce-cli containerd.io

This installs the Docker engine (docker-ce), Docker CLI (docker-ce-cli), and containerd, which is the runtime that Docker uses to manage containers.

Start the Docker Service:

Bash
sudo systemctl start docker

This starts the Docker service, enabling container management on your system.

Enable Docker on Startup:

Bash
sudo systemctl enable docker

This ensures that Docker starts automatically whenever the system boots.

Install Docker Compose:

Bash
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

This command downloads the Docker Compose binary for your specific OS and architecture (uname -s and uname -m retrieve system name and machine hardware, respectively).

Make Docker Compose Executable:

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

This grants execution permissions to the Docker Compose binary.

Conclusion

Following these steps, you can install and configure Docker and Docker Compose on a CentOS-based Linux distribution. Docker allows you to run containers, and Docker Compose is a tool that simplifies managing multi-container applications.

Shares: