Docker installation - Ubuntu 20.04 LTS

Install on Ubuntu (easy way)

# install
sudo apt install -y docker.io docker-compose

# use Docker as a non-root user
# get rid of having to sudo or be root
sudo usermod -aG docker $(whoami)

# logout and login again for the group change to work

You don't need to install the long manual way, docker.io is already provided as a package in the Ubuntu repos and the version is fairly up to date (19.03.8-0ubuntu1 as of this writing, which is the latest version). You can check which version comes with the commandapt info docker.io

docker-apt-info-version

note that in Ubuntu docker is a tray plugin, while docker.io is the Docker containerization software. the name docker wasn't available so they went with docker.io

Install on Ubuntu (hard way)

Since i had already written this, i'm keeping the content. But the one-liner command above is good enough

# uninstall any existing docker
sudo apt-get remove docker docker-engine docker.io containerd runc

# enable https repos
sudo apt-get install -y 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 -

# add repo
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

# install Docker
sudo apt-get update && sudo apt-get install -y docker-ce docker-ce-cli containerd.io

Since the release for 20.04 LTS is not available as of this writing, i'm adding the bionic repo instead ref. bionic instead of $(lsb_release -cs)

User permissions

If you keep getting permission denied errors like these

docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.

This means you need to run the command with sudo. You can get rid of having to sudo by adding yourself to the docker user group

sudo usermod -aG docker $(whoami)

Make sure you logout and log back in after this in order for the change to work

Links

Please note that this site and the posts on it are, and will always be, a work in progress. If i waited for perfection, i’d never get anything done.