- Remove existing installations
sudo apt-get remove docker docker-engine docker.io containerd runc
- Update the apt package index and install packages to allow apt to use a repository over HTTPS:
sudo apt update && sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
- Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Use the following command to set up the stable repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Update the apt package index, and install the latest version of Docker Engine and containerd,
sudo apt-get install docker-ce docker-ce-cli containerd.io -y
- If you want to avoid typing sudo whenever you run the docker command, add your username to the docker group:
sudo usermod -aG docker ${USER}
- To apply the new group membership, reboot or logout and log back in
- Official Docs
- DigitalOcean's tutorial