Intro

Docker and docker-compose are a very common tools for developing and deploying applications.

In this post I will cover the process of installing Docker engine and Docker compose on Centos 8 minimal.

Software Versions Used In This Post

  • Centos Minimal - 8.2.2004
  • Docker Engine CE - 19.03.14
  • Docker Compose - 1.27.4

Pre-Flight Check

Ensure that there are no default versions of Docker install. There should not be, but it's worth confirming.

cmd
rpm -qa | grep docker

Docker Install

Add the Docker community edition repository.

cmd
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

Install Docker, the CLI tools and containerd.

cmd
sudo dnf install -y docker-ce docker-ce-cli containerd.io

Start and enable Docker.

cmd
sudo systemctl start docker
sudo systemctl enable docker

Add the docker0 interface to the trusted zone in firewalld .

Important
This allows containers to resolve hostnames to IP addresses. Without it, any thing that relies on name resolution will not work.
cmd
sudo firewall-cmd --permanent --zone=trusted --add-interface=docker0
sudo firewall-cmd --reload

Add your user to docker group.

cmd
sudo usermod -aG docker $USER

Now logout and log back in or run the newgrp docker command.

Verify Docker Install

Confirm that you can run docker commands.

cmd
docker pull hello-world

# Output

Using default tag: latest
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:e7c70bb24b462baa86c102610182e3efcb12a04854e8c582838d92970a09f323
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

Docker Compose Install

Install the docker-compose binary from the Github release page.

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

Make the docker-compose binary executable.

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

Symlink the docker-compose binary into a location in your $PATH .

cmd
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

Update the docker-compose binaries permissions.

cmd
sudo chgrp docker /usr/local/bin/docker-compose
sudo chmod 750 /usr/local/bin/docker-compose

Verify Docker Compose Install

Confirm that you can run docker-compose commands.

cmd
docker-compose --version

# Output

docker-compose version 1.27.4, build 40524192

Outro

This post covered the process of installing Docker engine and Docker compose on Centos 8 Minimal.