Home How to install Docker on Ubuntu 20.04
Post
Cancel

How to install Docker on Ubuntu 20.04

Install Docker

Update the system.

1
sudo apt-get update

Install required libraries.

1
sudo apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common

Add Docker repository.

1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - 

Add Repository to the system.

1
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" 

Install Docker and Docker Compose.

1
sudo apt install -y docker-ce && sudo apt install docker-compose

Check that it’s working properly.

1
sudo systemctl status docker

The output should look like this:

1
2
3
4
5
6
7
8
9
10
docker.service - Docker Application Container Engine 
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled) 
Active: active (running) since Mon 2020-05-25 14:45:19 UTC; 1min 14s ago
Docs: https://docs.docker.com
Main PID: 856 (dockerd)
Tasks: 10
Memory: 42.8M
CPU: 209ms 
CGroup: /system.slice/docker.service 
        └─856 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Create a simple container to test.

1
sudo docker run hello-world

Install docker-compose

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

Run Docker commands as non root user

1
sudo usermod -aG docker $USER && newgrp docker

Check to see if you can run a docker command as non root user

1
docker run hello-world
This post is licensed under CC BY 4.0 by the author.