+1 (506) 500-5957 sales@monovm.com

How to install Docker on Ubuntu?

Get started with Docker on Ubuntu by following our easy-to-follow installation guide. Learn how to install and configure Docker on your Ubuntu system and take advantage of the power of containerization to streamline your development process.

Posted: 28 Mar, 23 Updated: 28 Mar, 23 by Susith Nonis 6 Min

List of content you will read in this article:

A technology called Docker allows users to package and run apps inside containers. Similar to virtual machines in that they are isolated, containers are more portable and resource-friendly.

By enabling you to create and run apps on any Docker host, Docker aids in making applications portable. From your laptop to the cloud, a container image can be utilized without modification anywhere Docker is available. 

This eliminates variations between runtime contexts, simplifying the developer experience. Moreover, the container structure makes it simple to spread programs across several physical servers in response to shifting demand.

In this article, we will show you how to install Docker on Ubuntu and use it. 

To ensure you receive the most recent stable application version, install Docker from the official Docker repository. 

Install Docker after adding the new package source to Ubuntu to access the official Docker repository. The steps are as follows:

Step 1: Updating the Package Repository

The system's package repository can be updated, and the most recent required packages can be installed by running the following command:

sudo apt update

To continue the upgrade, enter your root password when requested and hit Enter.

Step 2: Install Prerequisite Packages

To use packages over HTTPS, the apt package manager needs a few prerequisite packages installed on the system. 

To enable Ubuntu to access the Docker repositories over HTTPS, enter the following command:

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

The above command:

  • enables the transfer of files and data over HTTPS for apt.
  • Gives the system the ability to verify security certificates.
  • Installs the data-transfer program curl.
  • Adds scripts for managing software.

Step 3: Add the GPG key

A GPG key confirms a software package's legitimacy. Run the following code to add the GPG key for the Docker repository to your machine:

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

The result should show OK, confirming the accuracy.

Step 4: Add Docker Repository

To add the Docker repository to apt sources, use the following command:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

This command updates the package database with the most recent Docker packages and adds the official Docker repository.

Step 5: determine Installation Source

To make sure the source for the Docker installation is the Docker repository and not the Ubuntu repository, run the apt-cache command. 

The apt-cache tool looks up the previously added Docker packages in the apt package manager's cache.

Execute the command line:

apt-cache policy docker-ce

The output identifies the most recent version in the newly inserted source repository.

Step 6: Install Docker on Ubuntu

To install Docker on Ubuntu, use the command below:

sudo apt install docker-ce –y

Hold off until the installation is finished.

Step 7: Check Docker Status

Verify that Docker is set up, that the daemon is running, and that the process is set to launch at boot. Execute the command line:

sudo systemctl status docker

Using the default Ubuntu repository is another method for installing Docker on Ubuntu. Although installation is simpler, the Docker package might not be the most recent version. 

The instructions below will help you install Docker using the default repository if you don't care about having the most recent version. 

Step 1: Updating the Repository

Run this code to make sure the local system package repository is updated:

sudo apt update

When prompted, enter the root password and wait for the procedure to be completed.

Step 2: Install Docker

To install Docker, use this command:

sudo apt install docker.io –y

Any prompt during installation is automatically answered with a yes when the -y parameter is specified.

Step 3: Install dependencies

Use the following command to install all the Docker dependency packages:

sudo snap install docker

This command uses the Snap package manager to install all dependencies.

Step 4: Verify the installation

Use the status command to see if Docker was installed correctly, or look at the program version. Run this command to view the Docker daemon status:

sudo systemctl status docker

You can also run the following command to determine the software version:

docker –version

The Docker convenience script automates the installation of all Docker components. Since it isn't interactive, you may relax as your system prepares for you.

Download the script first:

curl -fsSL https://get.docker.com -o get-docker.sh

Run the script now with root permissions:

sudo sh get-docker.sh

Executing docker install script

Hold off till the writing is finished. A confirmation message indicating the installation of Docker ought to appear.

The script is intended to be a universal remedy. Its actions cannot be changed without explicitly altering the script's source code. 

Also, since it won't update dependencies to the most recent versions, it is not intended to do Docker updates.

A well-liked tool for creating and distributing software in packages called containers is called Docker. One of the most well-liked Linux distributions is Ubuntu, and Docker offers strong support for this operating system.

By setting up Docker on Ubuntu, you may create a perfect platform for your development projects by leveraging small virtual machines that share the kernel of Ubuntu.

You’ll have no problem installing Docker on Ubuntu by reading this article. 

People also read: 

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.