Install Docker on Ubuntu/Linux Mint/PopOS

The official docker installation guide provides commands to install the latest Docker on Ubuntu machines but the command to add the docker repository is too specific to Ubuntu. In this article you will find a step by step guide to install the latest Docker using the official PPA on Ubuntu or any Ubuntu derivatives such as Linux Mint, Elementary OS, Pop OS, etc.

Step 01:

If you have any older versions of docker installed on your machine, remove them first using the following command:

sudo apt remove docker docker-engine docker.io containerd runc


Step 02:

Install the following dependencies that are required in the installations process.

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release


Step 03:

Enter the following command to add the official GPG key to your system.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg


Step 04:

This is the time to execute a distribution specific command. If you are using Ubuntu/Pop OS, enter the following command on a x86_64 machine.

echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

If you are using Ubuntu/Pop OS on an ARM computer, use the following command instead:

echo \
  "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

If you are using Linux Mint or any other Ubuntu derivatives, use the following command on a x86_64 machine:

source /etc/upstream-release/lsb-release
echo \
  "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $DISTRIB_CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Similarly, the command for any Ubuntu derivatives running on an ARM machine is given below:

source /etc/upstream-release/lsb-release
echo \
  "deb [arch=arm64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
  $DISTRIB_CODENAME stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Note that in Ubuntu, we use the lsb_release -cs to get the Ubuntu version name. On all other Ubuntu derivatives, we are using the upstream version which will be the version of the upstream Ubuntu distribution. Debian users, may have to find the downstream version of the Ubuntu.


Step 05:

Update the package index and install the latest docker packages using the following command:

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io


Step 06:

Run the following command to test the installation of Docker. This command will run the hello world docker container and print the Hello from Docker! message.

sudo docker run hello-world

If you do not want to run docker with sudo every time, follow the article: Running Docker Without Sudo on Linux to run Docker without admin privilege.

Previous
Next Post »

Contact Form

Name

Email *

Message *