January 24, 2025

How to Install Docker Engine on Linux Ubuntu


In this tutorial, we explain how to properly install Docker Engine on Linux Ubuntu. This tutorial is designed for people who are relatively new to Linux Ubuntu and Docker. However, we believe that this tutorial might also be useful for more experienced Linux Ubuntu users.

There are two possibilities for installing and running Docker on Linux Ubuntu. The first possibility is to install and run Docker Engine. Docker Engine is released under the Apache license 2.0, and consequently, it is free for personal and commercial use. Furthermore, Docker Engine is simple to use, and you can run it from the command line.

The second possibility is to run Docker by using Docker Desktop. Docker Desktop is a full GUI for running and configuring Docker. It might be free for personal use and learning, otherwise, you need to pay for the license.

My suggestion to everyone is to start with Docker Engine, and then if you need additional capabilities, use Docker Desktop. The YouTube tutorial on how to install Docker Desktop is given below.

Installation Instructions

First, make sure that you have an appropriate Linux Ubuntu distribution. You need to have any of these Linux Ubuntu versions

  • Ubuntu Noble 24.04 (LTS)
  • Ubuntu Jammy 22.04 (LTS)
  • Ubuntu Focal 20.04 (LTS)
  • Ubuntu Oracular 24.10

To verify the Linux Ubuntu distribution, open a terminal and type

lsb_release -a 

The output of this command will contain the Linux Ubuntu distribution version.

The next step is to uninstall packages that can potentially create conflicts with Docker Engine. To do that, run this command

 for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done

The next step is to setup Docker’s apt repository:

sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update && sudo apt-get upgrade

The next step is to install Docker packages

 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

The next to verify the Docker installation

 sudo docker run hello-world

The final step is to enable us to run Docker without using sudo. To do that, first create a Docker group

 sudo groupadd docker

The next step is to add the user to the group

 sudo usermod -aG docker $USER

To activate the changes to the group, type this

newgrp docker

The finally step is to verify that we can run the hello world example without sudo. Consequently, type in the terminal

 docker run hello-world