How to install Docker on Ubuntu 20.04

Estimated reading: 4 minutes 143 views

Docker is a free and opensource containerization platform that allows developers to develop and deploy applications in isolated environments called containers. Containers ship with their own libraries and dependencies that make it possible to develop standardized code in complete isolation from the host system. In this guide, you will learn how to install and remove Docker on Ubuntu 20.04 LTS.

1. Prerequisites

  • Ubuntu or any other Debian-based distro
  • Terminal Access
  • Sudo or root privilege
  • Internet accessNote : Although the commands used in this tutorial are specific to Ubuntu systems, all of these methods are also valid for any other Linux-based system

2. Install Docker from the Repository System

a) Update your system

Always update your system repositories before installing

$ sudo apt update

b) Install Docker from Local Repository

$ sudo apt install docker.io

c) Check Docker Version

Check the Docker version with the following command

$ docker --version

You may find the version is not the latest available, you have to install it from its official repositories to get the latest version available.

3. Install Docker from Docker Official Repository

a) Update your system

Update your system. Update the system repositories by running the following command:

$ sudo apt update

b) Install dependencies

Install dependency packages to access Docker repositories over HTTPS.

$ sudo apt install apt-transport-https ca-certificates curl software-properties-common

c) Add GPG Key

To add the Docker repository GPG key, run the following command:

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

d) Install Docker Repository

Next, to install the Docker repository, run

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


And update your system again

$ sudo apt update

e) In stall Docker

Finally, install Docker using the following command:

$ sudo apt install docker-ce

f) Check Docker Version

$ docker --version

g) Start and enable the Docker service

$ sudo systemctl start docker
$ sudo systemctl enable docker

-Verify that the Docker service started up according to its state.

$ sudo systemctl status docker


You can see that the Docker service is running.

h) Stop and disable the Docker service

$ sudo systemctl disable docker

Disabling services will ensure that Docker services will not start automatically at system boot

$ sudo systemctl stop docker

4. Using Docker in Ubuntu

a) Check if Docker installed on Ubuntu successfully

To verify that docker was properly installed, we are going to pull and run a sample image from Docker hub. The image name is hello-world and when run, it spawns and runs a container that prints the message hello from Docker ! on the terminal. The command will be:

$ docker run hello-world

b) Execute Docker commands as a non-root user

By default, only the root account and people with sudo privileges can execute Docker commands.To execute Docker commands as a non-root user, you will need to add that user to the docker group created during the installation of the Docker CE package. To do that, enter the following command:

$ sudo usermod -aG docker $USER

$USER is an environment variable, it will contain the name of the currently logged in account.
Please log out and log back in to update this change.

c) Searching images in Docker

$ docker search

d) List all Docker images in Docker

$ docker images

e) List all containers in Docker

$ docker container ps -a

5. Uninstall Docker on Ubuntu

You can remove Docker from your system with the following command:

$ sudo apt-get remove docker docker-engine docker.io

$ sudo apt-get remove docker.ce

Docker is an extremely versatile technology with many different applications in software development. Docker makes it easy to distribute software in diverse settings and is great for testing and prototyping applications, whether you’re a software developer or working in DevOps.

This tutorial discussed how you can install and uninstall dockers on your Ubuntu system. It also briefly covers some basic Docker usage.

Good Lood!

Leave a Comment