Step-by-Step Guide: Installing Docker on Ubuntu

install Docker on ubuntu

Virtualization is a powerful way of extracting the most out of your cloud infrastructure. Whether you wish to deploy or develop applications, you need a platform that delivers virtualization as a service to your processes.

Docker is an open-source technology that is used to deploy applications through isolated containers that contain all the resources required to run an application.

In this article, we’ll take a look at how you can install Docker on Ubuntu 22.04. We’ll also go into some detail about the idea of containers and the benefits Docker brings to your processes.

Let’s start with an introduction to containers.

Table Of Content

  1. What are Containers?
  2. Benefits of Containers
    1. Lightweight
    2. Portability and Platform Independence
    3. Ideal for Modern Development Practices
  3. What is Docker?
  4. How to Install Docker on Ubuntu 22.04
  5. Install Docker on Ubuntu 22.04: How to Get Started
  6. FAQ – Install Docker on Ubuntu
  7. Conclusion

What are Containers?

The idea of containers as a way of running applications in isolation has been around for more than a decade. In practical terms, containers provide a layer of abstraction, allowing applications to be packaged with all their dependencies so they can run in any environment.

By taking advantage of OS virtualization primitives such as namespaces and control groups (cgroups), containers completely isolate application processes and protect them from interference and leaks.

In addition, a containerized environment offers control over the allocation of hardware resources (CPU, memory, and disk) available to a container.

Containers are faster than virtual machines because they don’t require a guest operating system in every instance. Instead, they simply leverage the features and resources of the host OS to provide a working foundation for each container

If you want to learn more about containers, you can read Containerization vs Virtualization: Making the Right Choice for Your Infrastructure.

Benefits of Containers

Compared to other virtualization technologies, containers offer significant operational benefits, such as:


By sharing the machine OS kernel, containers eliminate the need for full OS instances for the applications. This reduces the size of container files and makes them more resource-efficient.

Portability and Platform Independence

Since all files, dependencies, and assets required by the application are included in the container, you can set up and initiate a container anywhere you need. This also means that you only need to write an app once and then run it on any compatible environment, including local devices, cloud, and on-premises environments, without re-configuring it.

Ideal for Modern Development Practices

With their portability, consistency across platforms, and small sizes, containers are ideal for modern development workflows and patterns that involve regular code deployments in small increments. Containers are a great fit for CI/CD pipelines commonly used in DevOps, serverless, and microservices architectures.

Now that you know what containers are and the benefits they offer, let’s talk about Docker, a great platform for setting up containers in a virtual environment.

What is Docker?

Docker is a great platform for packaging an application or a set of services in containers.

A Docker container contains all the libraries and components required to run the application. From a practical point of view, a container is like a simplified virtual machine that functions independently of the underlying operating system.

In Docker, containers are generated from images that contain a complete operating system and/or pre-installed applications.

You can find a Docker image for all popular applications, including OS, DBMS, CRM, and programming languages. We strongly recommend checking out the official Docker image repository for an image. In case you can’t find it, you can create your own image and deploy it to your Docker platform.

Let’s see how you can install Docker on Ubuntu 22.04 in a couple of easy steps.

How to Install Docker on Ubuntu 22.04

Before moving towards the steps to install Docker on Ubuntu machine, make sure that you have an administrator-level account on the target machine.

Now follow these steps:

Step # 1: Access the Server (or VPS)

Connect to the target machine over the SSH, using your preferred client.

Step # 2: Update the System

Run the general system update command. This ensures that all the system files are properly updated so that Docker can be installed without any worries.

# sudo apt update

Update the system to install Docker on ubuntu

# sudo apt upgrade

upgrade the system to install Docker on ubuntu

Step # 3: Install the prerequisite packages

After the system update, the next step is to install the necessary packages. For this, run the following command:

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

install prerequisite to install Docker on ubuntu

Step # 4: Add the Official Docker Repository

Now that the system is prepared and ready, let’s add the Official Docker repositories. This is a two-step process.

First, use the following command to add the GPG key:

# curl -fsSL | sudo apt-key add –

You will get the simple OK that indicates that the step has been successfully completed.

Add Official Docker Repository to install Docker on ubuntu

Now, add the Docker repository with the following command:

# sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"

Add Official Docker Repository to install Docker on ubuntu

Notice that we’re opting for the stable version to avoid any issues while using the platform.

Now, update the system repository information with the following command:

# sudo apt update

Next, we need to make sure that the installation process uses the Docker repository rather than the default Ubuntu repository. For this, use the following command:

#apt-cache policy docker-ce

add cache policy docker to install Docker on ubuntu

Note that in the following screenshot, you can see that the repo is downloaded from the Docker download site.

Step # 5: Install Docker on Ubuntu

At this point, we can proceed with the installation. For this, enter the command:

# sudo apt install docker-ce

Use this command apt install docker-ce to install Docker on ubuntu

You can see that during the installation process, additional files are being downloaded to address dependencies.

Once the command finishes, Docker will be installed and ready for use on your Ubuntu machine.

Check Docker Installation & Version

After installing Docker, it’s always a good idea to check the Docker version and status to ensure everything is working as intended.

Let’s start by checking the status.

Check Docker Status

Use the following command to check Docker Status:

# sudo systemctl status docker

Check the docker status after the installing Docker on ubuntu

As you can see the service’s status is active

Check Docker Version

Run this command to check the Docker version you just installed:

# Docker --version

Check the version after installing Docker on ubuntu

Hope these steps are helpful to install docker on ubuntu moreover you can also install git on ubuntu and install postgresql ubuntu.

Install Docker on Ubuntu 22.04: How to Get Started

Here are a few basic operations you can perform when you install docker on ubuntu newly.

We highly recommend you start with the traditional Hello World image to test the operational aspects of the platform. Use the following command to run the image:

# sudo docker run hello-world

You’ll see something like the following:

Hello from Docker!

This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

1. The Docker client contacted the Docker daemon.

2. The Docker daemon pulled the “hello-world” image from the Docker Hub.

3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading.

4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:

For more examples and ideas, visit:

Using Docker Commands

Docker commands consist of options, commands, and arguments. The syntax is as follows:

docker [option] (command) [arguments]

Use the following command to view all available commands:

# docker

You can also view the details of a command, including the syntax, by adding the help flag. The syntax of the is :

docker {{{command}}} --help

This how you get started after installing Docker on ubuntu

After the process of how to install docker on ubuntu you get started and if you are a programmer and works on python you can also install python on ubuntu.


Docker has revolutionized the way software is deployed in a virtualized environment. Thanks to Docker, developers can build applications without worrying about environment-related issues. Docker containers have all the required code and assets in a convenient package that would run in any compatible environment without any issues.

This tutorial covers the process of how to install Docker on Ubuntu 22.04. We also described how you can test the Docker installation and get help. We also let you install docker on CentOS and install mysql on centos for your ease.

Let us know about your Docker installation experience in the comments.

FAQ – Install Docker on Ubuntu

1- Can I install docker using GUI?

Docker can be installed via a graphical user interface (GUI), but the actual process of installation is typically done through the command line. This is because Docker is designed to be run on a server where a GUI may not be available.

However, on a system with a GUI, you can use the terminal or command prompt to run the necessary commands to install Docker. The installation process may vary slightly depending on your operating system, but you can find step-by-step instructions for installing Docker on various platforms on the Docker website.

2- What is the difference between Docker CLI and Docker GUI?

The Docker CLI is a command-line tool for managing Docker, while a Docker GUI is a graphical interface for managing Docker through a visual representation of the Docker environment. The Docker CLI is often used by developers and system administrators. The Docker GUI is designed to make it easier for new users or those who prefer a visual interface to manage Docker.

3- What is the latest version of Docker for Ubuntu?

At the time of writing this tutorial, the latest version of Docker available for Ubuntu is Docker 20.10.7. However, it’s important to note that the exact version of Docker available for your system may vary depending on your specific Ubuntu release and the repository you’re using to install Docker.
You can check the version of Docker installed on your system by running the following command in your terminal:
docker –version
If you want to upgrade to the latest version of Docker, you can follow the steps outlined in the Docker documentation for your specific operating system.

4- How to start the Docker service?

To start the Docker service on Ubuntu, use the following command:
#sudo systemctl start docker

To check the status of the service:
#sudo systemctl status docker

If the service is not running, you can restart it with the following command:
#sudo systemctl restart docker

5- Where is Docker located in Ubuntu?

In Ubuntu, Docker is typically installed in the /usr/bin directory. This is where you will find the Docker executable, which you can run from the command line.
You can check the location of the Docker executable by using the which command:
# which docker
This command will output the full path to the Docker executable on your system, which should be /usr/bin/docker.
In addition to the Docker executable, there are other related files and directories that are used by Docker, including configuration files, data directories, and more. These files and directories are typically located in the /var/lib/docker and /etc/docker directories, among others.

6- Can I install Docker without administrator access?

You can add your user to the docker group to run Docker commands without requiring administrative rights. However, note that this practice is considered a security loophole, and is generally not recommended.

How do I enable Docker for all users?

To enable Docker for all users, create a symbolic link to the Docker executable in a directory included in the PATH environment variable for all users, such as /usr/local/bin. Example command: sudo ln -s /usr/bin/docker /usr/local/bin/docker. Note that by enabling access to Docker to users, you might be exposing your system to vulnerabilities.

7- How can I upgrade the Docker engine?

To upgrade the Docker engine on Ubuntu
Update the package index with sudo apt-get update
Install the latest version of Docker with sudo apt-get install docker-ce
Start the Docker daemon with sudo systemctl start docker
Verify the upgrade with docker version.
It is important to backup data and test the upgrade in a test environment before proceeding, as compatibility issues may arise.

8- How to uninstall Docker from the server?

To uninstall Docker from an Ubuntu server
Stop the service with sudo systemctl stop docker
Remove the packages with sudo apt-get remove docker-ce docker-ce-cli
Remove any remaining files with sudo rm -rf /var/lib/docker
Verify the uninstallation with docker

. Note that this will also remove containers, images, and volumes, so backup any important data before proceeding.