How To Install Docker CE on Linux Systems

Posted on 205 views

How to Install Docker CE on Ubuntu / Debian / Fedora / Arch Linux and CentOS Linux systems ?. 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 CE on Ubuntu Linux

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:           20.10.18
 API version:       1.41
 Go version:        go1.18.6
 Git commit:        b40c2f6
 Built:             Thu Sep  8 23:11:43 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.18
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.6
  Git commit:       e42327a
  Built:            Thu Sep  8 23:09:30 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 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.10.2

2) Install Docker CE on Debian Linux system

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 CE on Fedora Linux

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 CE on CentOS / Rocky Linux / AlmaLinux

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 CE 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 CE on RHEL Server

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 CE 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

After installing Docker, you may be interested in:

coffee

Gravatar Image
A systems engineer with excellent skills in systems administration, cloud computing, systems deployment, virtualization, containers, and a certified ethical hacker.