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 🙂
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
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.
Step 3: Test the Installation with
sudo docker version
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!
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
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
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.
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.
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: