Skip to main content

1. Install Docker

First, uninstall old versions of docker:

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

Set up the repository for docker, so that it will automatically update with sudo apt update & sudo apt upgrade:

1. Update apt packages using sudo apt update

2. Next install basic packages to be able to run docker:

sudo apt-get install ca-certificates curl gnupg lsb-release

3. Add Docker's official GPG key:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

4. Settings up the docker repository:

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

5. Install Docker Engine:

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

Receiving a GPG error when running apt-get update?                                                                                                    Your default umask may not be set correctly, causing the public key file for the repo to not be detected. Run the following command and then try to update your repo again: sudo chmod a+r /etc/apt/keyrings/docker.gpg.