How to Install Docker on Ubuntu 20.04

Jayashree
May 20, 2022
5 min read

Introduction Docker is a platform that allows users to develop, ship, and run applications. It also allows users to distinguish the applications and infrastructure so that software can get delivered quickly. Infrastructure can get managed the same way an application gets managed. The Docker Methodologies help in delivering the code quickly by reducing the delay that occurs between writing code and executing the code. Overall, Docker simplifies the application management process using containers. Containers are like virtual machines, with the difference that they are portable, resource-friendly, and not dependent on the operating system. Learn more about Docker and its container on E2E cloud blogs. In this article, you will learn how to install Docker in Ubuntu 20.04. Learn the two methods to install Docker in Ubuntu. Let us get started.

Prerequisites for Installing Ubuntu ● Ubuntu 20.04 and 64-bit OS ● Account having sudo permissions ● Command-line terminal ● Optional Docker repositories

How to Install Docker on Ubuntu 20.04 The installation of Docker on Ubuntu 20.04 is easy. It can get done using two ways as mentioned below:

  1. Install Docker using the official repository
  2. Install Docker using the default repositories The Method 1 that allows installation using the official repository allows users to install the latest version. While using the default repository to install Docker, the latest version of Docker may not get installed. Method 1: Install Docker Using Official Repository Step1: Update the local repository Open the terminal window and update the local repository. Get Docker from the official Docker website to ensure that you are using the latest version of the package. Sudo apt update The command lets the update process get complete.

Step2: Download dependencies Download and install the prerequisite packages that allows Ubuntu to use Docker repositories over HTTPS: Sudo apt install apt-transport-https ca-certificates curl software-properties-common The command: ● Installs curl that allows the data transfer ● Allows package manage to transfer data and files over HTTP by providing the required permissions ● Lets the system verify the security certificates ● Manage scripts that help to manage the software Step3: Add GPG Key This step adds the GPG Key of Docker to maintain authenticity. Curl –fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - Step4: Install Docker Repository The below command installs the Docker repository and adds it to the APT sources Sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable” Step5: Install the latest and updated Docker This command updates the repository packages and package database. Sudo apt update Use the below command to install the latest version of Docker Sudo apt –get install docker -ce Step6: Verify if Docker is installed The below command verifies the version of the Docker installed Docker –version The command will show the version as: Docker version 19.03.8, build afacb8h7g0 Step7: Enable Docker service In order to start the docker service, execute the below command Sudo systemct1 start docker Now, enable the docker service with the below command Sudo systemctl enable Docker You can also check the status of the command using the below command Sudo systemct1 status docker The output will show as Active: active (running) Method 2: Installation of Docker with Default Repositories

To install the Docker with the default repository, follow the below steps Step 1: Update Local Repository Run the below command on the command line terminal to update the local repository Sudo apt update Step2: Uninstall the older Docker version It is necessary to uninstall the older packages of Docker before installing the latest on Ubuntu 20.04 Sudo apt –get remove docker docker –engine docker.io Step 3: Install Docker Run the below command to install the Docker in Ubuntu 20.04. Sudo apt install docker.io Once the above command executes, it will ask for confirmation. Enter y and click on the Enter button. Notification will appear after the installation completes. Step 4: Check the installation of Docker The below command shows the version of Docker installed. Docker –version Step 5: Start the Docker Service Below command starts the docker service Sudo systemctl start docker After starting, enable the docker service Sudo systemctl enable docker Run the below command to find the status Sudo systemctl status docker The output will show the service as running as shown below: Active: active (running) The basic syntax for the Docker command Refer the below syntax to execute the docker commands: Sudo docker [option] [command] [argument] Conclusion Docker is one of the helpful tools that help to manage the application easily and reduce the time gap within writing code and running the application. In this article, the methods of installation of Docker in Ubuntu 20.04 are explained. Now you can install and run the Docker commands in Ubuntu 20.04 and get all the advantages of using Docker. E2E Cloud provides cloud solutions across all verticals, including Linux-based systems. Other services of E2E cloud include high memory cloud, high-performance computing, high disc space, and many more.