## Uninstall old versions sudo apt-get remove docker docker-engine docker.io containerd runc ## Install using the repository ### Set up the repository sudo apt-get install ca-certificates curl gnupg lsb-release ### Add Docker’s official GPG key: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dear mor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) 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 ## Install Docker Engine ### Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version: sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io ### To install a specific version of Docker Engine, list the available versions in the repo, then select and install: ### a. List the versions available in your repo: apt-cache madison docker-ce docker-ce | 5:20.10.11~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:20.10.10~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:20.10.9~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages docker-ce | 5:20.10.8~3-0~ubuntu-bionic | https://download.docker.com/linux/ubuntu bionic/stable amd64 Packages ### b. Install a specific version using the version string from the second column, for example, 5:20.10.11~3-0~ubuntu-bionic. sudo apt-get install docker-ce= docker-ce-cli= containerd.io sudo apt-get install docker-ce=5:20.10.11~3-0~ubuntu-bionic docker-ce-cli=5:20.10.11~3-0~ubuntu-bionic containerd.io ## Verify that Docker Engine is installed correctly by running the hello-world image. sudo docker run hello-world ## Manage Docker as a non-root user ### To create the docker group and add your user sudo groupadd docker sudo usermod -aG docker $USER ### Log out and log back in so that your group membership is re-evaluated. newgrp docker ### Verify that you can run docker commands without sudo docker run hello-world