How To Install Docker on Linux

How to Install Docker on Linux systems – Ubuntu / Debian / Fedora / Arch Linux / CentOS / Rocky / AlmaLinux ?. As of this article writing there are two main editions of Docker – Docker CE ( Community Edition) and Docker EE ( Enterprise edition). This article will be focused in the installation of Docker CE on various distributions of Linux operating system.

Docker is a container runtime engine which allows you to package an application with all of its dependencies into a standardized unit for software development.

Docker containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: coderuntimesystem toolssystem libraries – anything you can install on a server. This guarantees that it will always run the same, regardless of the environment it is running in.

Here we’ll cover installation of Docker CE on Ubuntu, Debian, Fedora, and CentOS and Arch Linux distributions.

1) Install Docker on Ubuntu

Uninstall Old version of Docker. Old versions of docker had the name docker or docker-engine. If you have it installed, first uninstall it.

sudo apt update
sudo apt remove docker docker-engine docker.io 2>/dev/null

The Docker CE package is now called docker-ce. Update the apt package index:

sudo apt update

Install packages to allow apt to use a repository over HTTPS:

sudo apt -y install lsb-release gnupg apt-transport-https ca-certificates curl software-properties-common

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/docker.gpg

Add stable repository:

sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Install docker ce:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

If you would like to use Docker as a non-root user, you should now consider adding your user to the “docker” group with something like:

sudo usermod -aG docker $USER
newgrp docker

Run the command below to see a version of docker installed.

$ docker version
Client: Docker Engine - Community
 Version:           27.5.1
 API version:       1.47
 Go version:        go1.22.11
 Git commit:        9f9e405
 Built:             Wed Jan 22 13:42:47 2025
 OS/Arch:           linux/amd64
 Context:           default

Server: Docker Engine - Community
 Engine:
  Version:          27.5.1
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.11
  Git commit:       4c9b3b0
  Built:            Wed Jan 22 13:41:09 2025
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.25
  GitCommit:        bcc810d6b9066471b0b6fa75f557a15a1cbf31bb
 runc:
  Version:          1.2.4
  GitCommit:        v1.2.4-0-g6c52b3f
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

To get more details about docker, run:

docker info

Check Docker Compose version using the commands:

$ docker compose version
Docker Compose version v2.24.7

2) Install Docker on Debian

Update the apt package index:

sudo apt update

Install packages to allow apt to use a repository over HTTPS:

sudo apt install lsb-release gnupg2 apt-transport-https ca-certificates curl software-properties-common -y

Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/debian.gpg

Set up the stable repository:

sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/debian $(lsb_release -cs) stable"

Install Docker Engine and its dependencies:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

3) Install Docker on Fedora

Uninstall Older versions of Docker:

sudo dnf remove docker docker-common docker-selinux docker-engine-selinux docker-engine 2>/dev/null

Configure Docker repository:

sudo dnf -y install dnf-plugins-core
sudo dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo

Install Docker CE:

 sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Start and enable docker service:

sudo systemctl start docker && sudo systemctl enable docker

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

4) Install Docker on CentOS / Rocky / AlmaLinux

On CentOS 7 you may need to do: Fix CentOS 7 Repositories Not Working

Uninstall old versions:

sudo yum remove docker docker-common docker-selinux docker-engine

Install required dependencies:

sudo yum -y install yum-utils device-mapper-persistent-data lvm2

Setup stable repo:

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

Install Docker CE:

sudo yum -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Start and enable docker service:

sudo systemctl start docker && sudo systemctl enable docker

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

Check service status:

systemctl status docker

5) Install Docker on SLES / OpenSUSE

The OpenSUSE SELinux repository must be enabled.

sles_version="$(. /etc/os-release && echo "${VERSION_ID##*.}")"
opensuse_repo="https://download.opensuse.org/repositories/security:SELinux/SLE_15_SP$sles_version/security:SELinux.repo"
sudo zypper addrepo $opensuse_repo 

Set up the Docker repository

sudo zypper addrepo https://download.docker.com/linux/sles/docker-ce.repo
 sudo zypper install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Start and enable Docker service

sudo systemctl start docker
sudo systemctl enable docker

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

6) Install Docker on RHEL

Add Docker repository

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo

Install Docker CE on RHEL system:

sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

Start and enable docker service

sudo systemctl start docker
sudo systemctl enable docker

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

7) Install Docker on Arch | Manjaro

Install yay:

Install Docker CE using yay:

$ yay -S --noconfirm --needed docker

Add your user account to the docker group:

sudo usermod -aG docker $USER
newgrp docker

Enjoy building your microservice applications using Docker.

Your IT Journey Starts Here!

Ready to level up your IT skills? Our new eLearning platform is coming soon to help you master the latest technologies.

Be the first to know when we launch! Join our waitlist now.

Join our Linux and open source community. Subscribe to our newsletter for tips, tricks, and collaboration opportunities!

Recent Post

Leave a Comment

Your email address will not be published. Required fields are marked *

Related Post

Welcome to our today’s tutorial on how to search text files using regular expressions like grep, egrep, fgrep, sed, regex. […]

In this guide, we show you how to manage files and permissions on Linux. The core security feature of Linux […]

Normally when backing data in a computer locally or to the cloud, there has been a struggle to get the […]

Let's Connect

Unleash the full potential of your business with CloudSpinx. Our expert solutions specialists are standing by to answer your questions and tailor a plan that perfectly aligns with your unique needs.
You will get a response from our solutions specialist within 12 hours
We understand emergencies can be stressful. For immediate assistance, chat with us now

Contact CloudSpinx today!

Download CloudSpinx Profile

Discover the full spectrum of our expertise and services by downloading our detailed Company Profile. Simply enter your first name, last name, and email address.