Table of Contents
  • Home
  • /
  • Blog
  • /
  • Discover the Easiest Way to Install Docker on Ubuntu With This Step-by-Step Guide!
November 7, 2023

Discover the Easiest Way to Install Docker on Ubuntu With This Step-by-Step Guide!

Discover The Easiest Way To Install Docker On Ubuntu With This Step By Step Guide

If you are new to the Docker environment, you don’t know what the Docker is. The short answer is that Docker is an open-source platform that provides the management interface to manage containers. Using Dockers, you can do a lot of administrative tasks on containers, like create, delete, run, stop, and configure containers. If you want to have a complete idea about Docker and containers, we have published several posts on the Dockers, Containers, architecture of Docker, and different versions of Docker Engine in this blog Please don’t forget to read those blog posts. If you are done with reading those posts and want to start playing with Docker on the live machine, it’s the first step to start with the installation of Docker Engine. We will cover a detailed step-by-step procedure to install Docker on Ubuntu in this post. If you want to know how to install Docker on Windows or Mac, we will have dedicated ‘How To’ guides for our Windows and Mac users.

Installing Docker on Ubuntu is a great way to get started with using containers for your development or production environment. It’s simple and straightforward and makes it easy to get up and running quickly. In this article, we’ll walk you through the step-by-step procedure to install Docker on Ubuntu. We’ll cover the prerequisites, downloading and installing Docker, using the Docker command line, running a Docker container, and some troubleshooting tips. With this guide, you’ll be able to get started with Docker on Ubuntu in no time.

Prerequisites to Install Docker on Ubuntu

It literately doesn’t require anything more other than a running 64-bit version of Ubuntu machine with a good internet connection. Before starting the installation process, make sure that your system meets the following prerequisites:

  • You are using the 64-bit version of one of these Ubuntu versions (16.04 or higher): Ubuntu Lunar 23.04, Ubuntu Kinetic 22.10, Ubuntu Jammy 22.04 (LTS), Ubuntu Focal 20.04 (LTS), or Ubuntu Bionic 18.04 (LTS).

  • Your system is compatible with x86_64 (or amd64), armhf, arm64, or s390x architectures.

  • A user account with sudo privileges.

  • A good internet connection.

To check the version of your Ubuntu machine. Run any of these commands:

$ cat /etc/os-release


$ hostnamectl

Two Different Ways to Install Docker on Ubuntu

Once you confirm all the prerequisites are met, the next step is to start the installation of Docker on your Ubuntu. There are two approaches to installing Docker on Ubuntu.

  1. Install Docker from the Package Manager.

  2. Install Docker using the install Script.

We will cover both approaches here. You can follow any approach that suits your requirement. Practically, installing using the script is a more convenient way to install Docker, the traditional package manager. However, the package manager sounds more formal.

How to Install Docker on Ubuntu Using Package Manager?

Docker Engine comes in two versions Community Edition (CE) and Enterprise Edition (EE). We will show you the installation of Community Edition in this demo tutorial. We will go over explaining the difference between the CE and EE versions here. We urge you to read this blog post Community Edition (CE) vs Enterprise Edition (EE) to know more about the differences.

Install Docker on Ubuntu Using Package Manager?

Step 1: Uninstall the Old Version of Docker

If you have older versions of Docker installed on your system (known as docker,, or docker-engine), or any installations of containerd or runc, you should uninstall them before proceeding. Use the following command to uninstall:

sudo apt-get remove docker docker-engine containerd runc

Step 2: Set Up the Docker Repository

Before you can install Docker Engine, you need to set up the Docker repository. This can be done by following these sub-steps:

*. Update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt update
sudo apt install ca-certificates curl gnupg

Docker’s official GPG key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

*.Set up the repository with the following command:

echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 3: Install Docker Engine on Ubuntu

It’s the actual potato. Now, you can install Docker Engine by following these steps:

*. Update the apt package index:

sudo apt update

Docker Engine, containerd, and Docker Compose:

sudo apt install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin

*.If you want to install a specific version, start by listing the available versions in the repository:

apt-cache madison docker-ce | awk '{ print $3 }'

sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING docker-buildx-plugin docker-compose-plugin

Note: If you see the packages are not available or available in a different source error in the execution of the above command. Check the source of the package repository. If your system is referring to the default Ubuntu package repository, then you are not going to have the docker packages in the default Ubuntu packages. Set up the docker repository and don’t forget to update the repository upon setting up. 

Use the
apt-cache command to check the source of the Docker repository.

sudo apt-cache policy docker-ce

Step 4: Verify Docker Installation

After the installation, verify that Docker Engine is installed correctly by running the hello-world image:

sudo docker run hello-world

To check the
Docker Engine version, run this command:

sudo docker version

To Check the status of the
Docker Engine service, run this command:

sudo systemctl status docker

That’s it! You should now have Docker Engine installed on your Ubuntu system.

In the future, if you want to upgrade Docker Engine, follow the same installation instructions, choosing the new version you want to install during the process.

How to Install Docker on Ubuntu Using the Install Script?

It’s no doubt that it is the fastest and easiest way to install Docker on Ubuntu. However, it has some caveats too. We recommend reading this information about the Docker Install Script.

Docker provides a streamlined script available at, designed to install Docker seamlessly in various development environments. The Docker installation script is not recommended for production environments due to its inherent limitations, yet its practicality for creating a provisioning script tailored to your requirements cannot be overlooked.

It is essential to consider that the Docker convenience script requires root or sudo privileges for execution. This script, known for its intelligence, attempts to detect your Linux distribution and version and then configures your package management system automatically. However, it’s important to note that it doesn’t offer much room for customization in installation parameters.

One unique feature of the Docker installation script is its ability to install dependencies and recommendations without seeking confirmation. While this may seem convenient, it may lead to the installation of a substantial number of packages, contingent on the current configuration of your host machine.

By default, the Docker convenience script installs the latest stable release of Docker, containerd, and runc. While this ensures that you’re up-to-date with the latest technology, it can lead to unexpected major version upgrades when provisioning a machine. Consequently, it is strongly advised to test upgrades in a controlled environment before deploying them to your production systems

It’s important to note that the Docker convenience script isn’t designed to upgrade an existing Docker installation. When utilizing this script to update an existing setup, dependencies may not be updated as expected, leading to potentially outdated versions.

Post-Installation Steps for Docker

After successfully installing Docker, you might want to perform a few post-installation steps to make sure everything is set up correctly and to optimize your Docker environment.

Enable Docker to Start on the Boot

Most likely you will want Docker to start when the system boots. To make this happen, run the following command:

sudo systemctl enable docker

Manage Docker as a Non-root User

By default, Docker requires root privileges to run. However, you can configure Docker to be run by non-root users to avoid having to use sudo it for every Docker command. If you don’t want to use sudo it whenever you run the docker command, create a Unix group called docker and add users to it. When the docker daemon starts, it makes the ownership of the Unix socket read/writable by the docker group.

  • Create the docker group:

sudo groupadd docker
  • Add your user to the docker group:

sudo usermod -aG docker $USER
  • Log out and log back in so that your group membership is re-evaluated.

  • Verify that you can run docker commands without sudo:

docker run hello-world

Configure Docker to Use a Proxy Server

If your machine uses a proxy server, Docker needs to be configured to use it. The exact steps depend on whether the proxy is HTTP or HTTPS and whether it requires authentication.

Detailed instructions can be found on the Docker proxy configuration page.

Adjust Memory and Swap Accounting

To enable memory and swap accounting on your Ubuntu system, you’ll need to set the GRUB_CMDLINE_LINUX value in the /etc/default/grub file. Detailed instructions can be found on the Docker runtime options page.

Please note that the exact steps might vary depending on the specific needs of your environment and the version of Ubuntu you are using.

Uninstall Docker Engine on Ubuntu

If you wish to uninstall Docker Engine, Docker CLI, and Docker Compose, you can use these commands:

  • Uninstall the Docker Engine, CLI, and Containerd packages:

sudo apt purge docker-ce docker-ce-cli

  • Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:

sudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd

You must delete any edited configuration files manually.

Installation of Docker on Ubuntu: Package Manager vs. Install Script

There are several ways to install Docker on an Ubuntu system, but two methods stand out for their ease of use and widespread application: using the Ubuntu package manager and using the Docker install script. Now you know both approaches. Let’s conclude our discussion by comparing these two methods, helping you make an informed decision on which installation process suits your needs best.

Installing Docker Using Ubuntu’s Package Manager

Ubuntu’s package manager, apt, is a powerful tool that handles the installation, upgrade, and removal of software on your system. To install Docker using the package manager, you’d typically update your package database, ensure that dependencies are met, and then install Docker. This process grants a high level of control over the installation and allows for seamless integration with Ubuntu’s system updates.


  1. Control: Using the package manager gives you control over what version of Docker you’re installing.

  2. Integration: Docker installed via the package manager will be updated along with other system updates.

  3. Stability: The Docker version in Ubuntu’s repositories is typically a well-tested and stable version.


  1. Outdated Version: The Docker version in Ubuntu’s repositories might not be the latest.

  2. Complexity: The installation process may seem complex to beginners.

Installing Docker Using the Docker Install Script

The Docker install script is a convenient method provided by Docker to automate the installation process. This script detects your Linux distribution and version, configures your package management system, and installs Docker along with its dependencies. While this method is quick and easy, it lacks the control offered by a manual installation using the package manager.


  1. Simplicity: The install script makes the installation process quick and easy.

  2. Latest Version: The script installs the latest stable version of Docker, ensuring you’re up-to-date.


  1. Less Control: The script doesn’t allow for much customization in the installation process.

  2. Potential Risks: Automatically installing scripts from the internet may pose a security risk.


The choice between using the Ubuntu package manager and the Docker install script depends largely on your specific needs and expertise. If you prefer control over the installation process and want Docker to be integrated with your system updates, the package manager method might be for you. On the other hand, if you prefer simplicity and want the latest stable version of Docker, the Docker install script would be the way to go.

In both cases, it’s essential to understand that Docker’s power comes with complexity. No matter the installation method, it’s crucial to familiarize yourself with Docker’s capabilities and potential pitfalls to make the most out of this powerful tool. Docker’s installation process on Ubuntu, whether through the package manager or the install script, is just the first step in leveraging the power of containerization. The journey ahead is filled with opportunities to learn, experiment, and innovate. With Docker, you’re well-equipped to face the challenges of modern application development and deployment.

We hope this post helps you Understand discovering the easiest way to install Docker on Ubuntu with this step-by-step guide. We are going to end this post for now. We will cover more information about the Docker in the upcoming articles. Please keep visiting for more such technical information. Visit our social media page on Facebook, Instagram,  LinkedInTwitterTelegramTumblr, & Medium and subscribe to receive information like this. 

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

Recently added

Best Reads

View All

Learn More About Cyber Security Security & Technology

“Knowledge Arsenal: Empowering Your Security Journey through Continuous Learning”

Cybersecurity All-in-One For Dummies - 1st Edition

"Cybersecurity All-in-One For Dummies" offers a comprehensive guide to securing personal and business digital assets from cyber threats, with actionable insights from industry experts.



View All

Learn Something New with Free Email subscription