How To Install Docker on Ubuntu 20.04?

by | 26.07.2021 | Tutorial

Docker is an open-source tool that makes managing application processes in containers much easier. Containers allow you to run your programmes in separate processes with their own resources. Containers are comparable to virtual machines, except they’re more portable, resource-friendly, and more reliant on the host OS.

Learn more about them here:

In this post, we would walk through how to install the stable version of Docker on Ubuntu 20.04. I am using an Azure VM for the demonstration, but you can use any system with Ubuntu 20.04! Installing in a VM, Cloud Instance, all are the same process 🙂

Let’s Start!

Prerequisites

To follow this tutorial, you will need the following:

  • One Ubuntu 20.04 server set up including a sudo non-root user.

Thing Not to Do

Don’t use apt package manager to install Docker. It’s generally outdated and won’t serve your purpose. We’ll download Docker from the official Docker repository to guarantee we obtain the most recent version. To do so, we’ll add a new package source, add the Docker GPG key to verify the downloads, and then install the package.

Also, remember that Docker Machine and Compose needs to be installed manually only on Linux. Docker Toolbox manages the installation on Windows and Mac.

Update your system

sudo apt update ##to update your packages
sudo apt upgrade ##to install the newer versions of the updated packages

Now, we have an updated system. We can go ahead to install docker!

Install Docker Engine

There are many ways to install docker, but the easiest way is to install it using a shell script!

Step 1: Go to get.docker.com, and you would find the following script. Use that to install docker without any hassle and in under few minutes.

# This script is meant for quick & easy install via:
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh

Step 2: Wait for few minutes.

Install docker

Step 3: Test the Installation with sudo docker version

install docker on ubuntu 20.04

Docker Machine

The machine allows you to set up Docker hosts on your computer, in the cloud, and in your own data centre. It sets up servers, installs Docker on them, and sets up the Docker client to communicate.

Step 1: You can find the latest release here on GitHub! Install using the commands on Linux!

install docker on ubuntu 20.04
curl -L <https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-`uname> -s`-`uname -m` >/tmp/docker-machine &&
    chmod +x /tmp/docker-machine &&
    sudo cp /tmp/docker-machine /usr/local/bin/docker-machine

Step 2: Test the Installation with sudo docker-machine version

install docker on ubuntu

Docker Compose

At last, you need to install Docker Compose. Compose is a tool that allows you to define and operate multi-container Docker applications. You configure your application’s services using Compose with a YAML file.  Compose work in all environments, including production, staging, development, testing, and continuous integration workflows.

So, let’s install the latest version! The GitHub page states that 1.29.2 is the latest version so, we use 1.29.2 on the command!

Step 1: To get the latest stable version of Docker Compose, use this command:

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

Step 2: Apply executable permissions to the binary:

sudo chmod +x /usr/local/bin/docker-compose

Step 3: Test the Installation with sudo docker-compose version

install docker

Executing the Docker Command Without Sudo (Optional)

Step 1: While performing docker tasks, you would not perform tasks without sudo access. The permission is required because the Docker daemon needs root access to run.

install docker on ubuntu 20.04

Step 2: Using sudo usermod -aG docker $USER where $user in this scenario, is hrittik would help.

Step 3: Logout and Login again to see the changes. We can see after the login that the Debian image is pulled without the Sudo command.

install docker on ubuntu 20.04

Final Thoughts

We went from a fresh VM to installing a fully functional Docker on an Azure VM in this tutorial. As mentioned above, you can use this on any machine running Ubuntu 20.04!

Feel free to subscribe to our newsletter, and don’t forget to check our blog section for high-level overview posts like the following:

Happy Containerizing!

Join the Community

The DevOps Awareness Program

Subscribe to the newsletter

Join 100+ cloud native ethusiasts

#wearep3r

Join the community Slack

Discuss all things Kubernetes, DevOps and Cloud Native

More stories from our blog

How to Install Portainer on Remote Server ft. VSCode?

How to Install Portainer on Remote Server ft. VSCode?

Portainer is one of the most popular and trusted GUI for managing Docker, Swarms, ACIs and Kubernetes. The company boasts on its’ website for having 500K users, and there’s no doubt to the number looking at how easy it makes managing the tools. This post goes on the...

What’s new in Python-Tuf v0.18.0?

What’s new in Python-Tuf v0.18.0?

Python-Tuf v0.18.0 recently came, and it is quite a big update with major and minor changes. We will go through all of those changes, additions, fixes and removals in this document. Without further a due, let's start! What is Python-Tuf? The Update Framework (TUF) or...

What’s new in Envoyproxy v1.19.1?

What’s new in Envoyproxy v1.19.1?

Envoyproxy came with its new version a few days ago. Version 1.19.1 comes with very few updates. It provides a few minor behavioural changes and a few bug fixes to make the user experience smoother. In this article, we will cover all of the new changes. Let's start!...

What’s new in Jaeger v1.26.0?

What’s new in Jaeger v1.26.0?

Jaeger v1.26.0 recently came. It has a few changes in its backend. In this article, we will cover all of this in a straightforward way. We will see all of the fixes and the new features that the devs have added. Let's start! What is Jaeger? Jaeger is a graduated CNCF...

Prometheus: As Simple As Possible

Prometheus: As Simple As Possible

Distributed systems help an organisation absorb countless benefits but at the cost of complexity. With the rise of the adoption of container orchestrators like Kubernetes, a need for monitoring and alerting systems came. One such system is Prometheus which is famous...

Bootstrap K3S Data: For Beginners

Bootstrap K3S Data: For Beginners

For Kubernetes users, handling data management tasks and other analysis needs can become difficult with the inclusion of edge based devices. Internet of Things (IoT) as a whole is designed to complement online services for devices commonly used by people such as air...

What’s new in Ingress-Nginx Controller v1.0.0?

What’s new in Ingress-Nginx Controller v1.0.0?

Ingress-Nginx controller for Kubernetes came with its new release almost a month earlier. I know we are pretty late in documenting this but trust me, this update is pretty big. And in this article, we will see all of the new features and essential bug fixes and...

Getting gRPC Right: An Introduction and Review

Getting gRPC Right: An Introduction and Review

The question of APIs and their best implementation through online websites will always remain a tough nut to crack as the web undergoes scaled changes each year. It’s hard to think that the web was once draped by HTML and PHP alone until CSS and Javascript made...

What’s new in TikV v5.0.4?

What’s new in TikV v5.0.4?

TikV came up with its new release this month. It is a small one, but we can see a couple of improvements and some bug fixes along the way. In this article, we will see all of those and view the recent changes. Let's start! What is TikV? TiKV is a graduate project of...

Interested in what we do? Looking for help? Wanna talk about software strategy?