Back

How to install Docker on Linux OS

How to install Docker on Linux OS

Docker is an OS-level virtualization platform designed to deliver applications in a lightweight, isolated runtime environment - containers. Containers share the same operating system resources, so they are much lighter than virtual machines, which ensures fast startup and reliable isolation. In this tutorial, you will learn how to install the Docker platform on a Linux operating system.


Preparation

  • Ubuntu 22.04/24.04/24.10 or Debian 12 Linux distribution
  • A user with root privileges
  • SSH access


Removing old packages

Before starting the Docker installation, remove any old packages to avoid conflicts with the official ones.

for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do
sudo apt-get remove -y $pkg 2>/dev/null || true
done


Installing Docker

Add the official Docker GPG key with the following commands:

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
Add the Docker repository to APT:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Finally, install Docker with this command:

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


Post-installation check

After installation, verify that Docker is working properly by running the hello-world container:

sudo docker run hello-world

This command pulls a test image and runs it in a Docker container. When the container starts, you will see a confirmation message in the terminal.


In summary, to install Docker on a Linux operating system, you need to add the Docker GPG keys, add the APT repository, and finally install Docker with a single command. If you have any questions or run into issues, feel free to contact our live support or email [email protected].

Similar tutorials

How to run Grafana in Docker containerGrafana is a leading open-source tool for visualizing time series data. It’s widely used to visualize data from various...

Read

How to Install a Graphical User Interface (GUI) on Ubuntu 24.04 Server OSThe Ubuntu Server operating system is normally designed to run without a graphical...

Read
Linux Tutorials