Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 22 - Install Docker

Related Posts


The script below will install docker using a PPA. This will allow you to always use the latest version of Docker without waiting on the Ubuntu package maintainers.

Docker will not start correctly if you are running a VPN connection. This will make it appear like installation failed when actually installation succeeded but docker will fail to start up correctly.


sudo apt update && sudo apt dist-upgrade -y

# Remove any existing installations...
sudo apt-get purge docker-engine -y
sudo apt-get remove docker docker-engine -y

# Stop script on any error
# need to set this AFTER purge so that doesn't error out on fresh install
set -e

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

# Add the key for docker
curl -fsSL | \
  sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

# Add the repository using key we just downloaded.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
  $(lsb_release -cs) stable" \
  | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

# Finally, install docker from the repository.
sudo apt update
sudo apt install -y \
  docker-ce docker-ce-cli docker-compose-plugin

# Add the current user to docker so that you can
# execute docker commands without using sudo
sudo usermod -aG docker $USER

echo "You will need to reboot before using docker."

This will install docker version: Docker version 20.10.16, build aa7e414 at the time of writing this post.


Last updated: 13th May 2022
First published: 13th May 2022