Installing docker on a Ubuntu 20.04 is pretty simple.
OS Versions
The procedure below would work on the following version of Ubuntu:
- Ubuntu 20.04
- Ubuntu 18.04
- Ubuntu 16.04
Update the apt package index
$ sudo apt-get update
Install the required packages to use HTTPS
$sudo apt-get install \apt-transport-https \ca-certificates \curl \gnupg-agent \software-properties-common
Add Docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Stable registry setup
$sudo add-apt-repository \"deb [arch=amd64] https://download.docker.com/linux/ubuntu \$(lsb_release -cs) \stable"
Install Docker Engine (CE) – Latest would be installed
$$sudo apt-get updatesudoapt-get install docker-ce docker-ce-cli containerd.io
Installing specific version of docker
List the available versions:
$ apt-cache madison docker-ce
Here is the syntax to install the specific version
$ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
Verify the install
Check if you can run a container:
$ sudo docker run hello-world
Check the version
$ sudo docker version
Running docker without “sudo”
Create “docker” group
$ sudo groupadd docker
Add yourself or the desired account(s) to the “docker” group
$ sudo usermod -aG docker $USER
Log out, and log back in!
Uninstall Docker Engine
Uninstall the Docker Engine, CLI, and containerd packages:
$sudo apt-get purge docker-ce docker-ce-cli containerd.io
To delete all images, containers, and volumes:
$ sudo rm -rf /var/lib/docker
Done!
