How to Install Docker in CentOS 8/RHEL 8

Docker is a daemon-based container engine that allows us to deploy applications inside containers.

Docker is available in 2 Versions

  • Docker CE (Community Edition)
  • Enterprise Edition (EE)

In this article, we are talking about the installation of Docker CE.

Step 1: Enable Docker Repository

Docker Packages are not available in CentOS 8/RHEL 8 so we need to enable the repository.

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

To check whether the package is added to the repo using the following command

dnf list docker-ce

Step 2: Install Docker

Use the following command to install Docker

dnf install docker-ce --nobest -y

Start and Enable the Docker

systemctl start docker
systemctl enable docker

To check the version of Docker use the command

docker --version

Run and verify a simple Docker Image

docker run hello-world

Install Docker Compose

Download the docker compose

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

Set the executable permission to docker-compose binary

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

To check the docker compose version

docker-compose --version

Basic Docker commands

Here given some of the basic commands that we can use in docker

  • docker run – Runs a command in a new container.
  • docker start – Starts one or more stopped containers
  • docker stop – Stops one or more running containers
  • docker build – Builds an image form a Docker file
  • docker pull – Pulls an image or a repository from a registry
  • docker push – Pushes an image or a repository to a registry
  • docker export – Exports a container’s filesystem as a tar archive
  • docker exec – Runs a command in a run-time container
  • docker search – Searches the Docker Hub for images
  • docker attach – Attaches to a running container
  • docker commit – Creates a new image from a container’s changes

Related Articles