Quick docker setup on Ubuntu Linux

Posted by Harald Nezbeda on Thu 23 July 2020

If you are not familiar with docker, I would encourage you to go through the official setup. In this article I want to resume the setup to just a few commands you need to run in order to get going. I often require this few steps when doing a fresh Ubuntu installation.

Dokcer setup

This set of instruction will remove any previouse installed version of docker, updates your local repositories, updates the SSl certificates, adds Docckers official GPG, adds the a new repository for docker, updates the sources and installs the comunity edition of docker.

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

Add user to docker group

In order yo use docker without sudo you need to add your current user to the docker group:

sudo usermod -aG docker $USER

A restart is required for this to take effect. Alternatively you can use the command bellow (please be aware that this will work only in the terminal where you executet the command):

newgrp docker

Test setup

Once you are done you should be able to run the docker hello-world as a regular user

docker run hello-world


Docker Hello World

Docker compose setup

For docker compose the command bellow will donwload the binary, add it to your /usr/local/bin/ folder and make it executable:

sudo curl -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose