Make sure your Ubuntu is up to date and patched.

$ sudo apt update
$ sudo apt upgrade

Docker is available within Ubuntu’s default software repositories but installation package available in the official Ubuntu repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository. To do that, we’ll add a new package source, add the GPG key from Docker to ensure the downloads are valid, and then install the package.

# First, uninstall old versions of Docker such as docker, or docker-engine
$ sudo apt-get remove docker docker-engine containerd runc

# Install a few prerequisite package 
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common -y

# Add GPG key for the official Docker repository
$ curl -fsSL | sudo apt-key add -

# Add the Docker repo to APT sources
$ sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

# Update the package database
$ sudo apt update

Finally install the Docker Community Edition’s latest version

$ sudo apt install docker-ce -y

$ sudo systemctl status docker

The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user root and other users can only access it using sudo. The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group.

# Create the docker group if not exsists
$ sudo groupadd docker

# Add your user to the docker group.
$ sudo usermod -aG docker $(whoami)

# Apply the new group membership by logging out
$ su - $(whoami)

# Confirm user group
$ id -nG

Have fun!


Leave a Reply

Your email address will not be published.