How to Install Docker on Ubuntu 24.04

By 

Updated on

8 min read

Install Docker on Ubuntu 24.04

When you start working with containers, Docker is usually the first tool you need. Most modern server software ships as container images, CI/CD pipelines build and test code inside containers, and many self-hosted applications only document a Docker-based setup.

Docker is an open-source containerization platform that allows you to quickly build, test, and deploy applications as portable containers. A container packages a single application together with all the software components and dependencies it needs, so it runs the same way on a local development machine, a test environment, or a cloud server.

This tutorial explains how to install Docker on Ubuntu 24.04 from the official Docker repository, verify that it works, and set up your user to run Docker commands without sudo.

Quick Reference

For a printable quick reference, see the Docker cheatsheet .

If you have installed Docker before and only need the commands, these are the core installation steps:

Terminal
sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc
sudo apt update
sudo apt 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
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world

The hello-world container confirms that Docker can download an image and start a container. The rest of this guide breaks the commands down step by step and covers non-root access, Docker Compose, updates, and uninstalling.

Supported Ubuntu Versions

Docker is available for installation from the standard Ubuntu repositories as the docker.io package, but those packages are often outdated. To ensure you get the latest stable version, we will install Docker from the official Docker repository.

At the time of writing, the Docker repository provides packages for the following Ubuntu versions:

  • Ubuntu 26.04 LTS (Resolute)
  • Ubuntu 25.10 (Questing)
  • Ubuntu 24.04 LTS (Noble Numbat)
  • Ubuntu 22.04 LTS (Jammy Jellyfish)
Info
Derivatives like Linux Mint are not officially supported (though they often work).

Prerequisites

Before you begin, make sure that:

  • You are running a 64-bit supported Ubuntu version
  • You have a user account with sudo privileges
  • Your system is connected to the internet and up to date
Warning
Published container ports can bypass UFW rules. Before exposing services with -p or --publish, review Docker’s firewall documentation .

Uninstall any old or conflicting Docker packages first to avoid any potential issues:

Terminal
sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc

Installing Docker on Ubuntu

Installing Docker on Ubuntu is relatively straightforward. We will enable the Docker repository, import the repository GPG key, and install the Docker packages.

Step 1: Update the Package Index and Install Dependencies

First, update the package index and install packages required to use repositories over HTTPS :

Terminal
sudo apt update
sudo apt install ca-certificates curl

Step 2: Import Docker’s Official GPG Key

Add Docker’s official GPG key so your system can verify package authenticity:

Terminal
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

Step 3: Add the Docker APT Repository

Add the Docker repository to your system:

Terminal
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") reads your Ubuntu codename from the OS release file. For example, on Ubuntu 24.04 it returns noble, and on Ubuntu 26.04 it returns resolute.

Step 4: Install Docker Engine

Tip
If you want to install a specific Docker version, skip this step and go to the next one.

Now that the Docker repository is enabled, update the package index and install Docker:

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

Installing a Specific Docker Version (Optional)

If you want to install a specific Docker version instead of the latest one, first list the available versions:

Terminal
sudo apt update
apt list --all-versions docker-ce

The available Docker versions are printed in the second column:

output
docker-ce/noble 5:29.6.1-1~ubuntu.24.04~noble amd64
docker-ce/noble 5:29.4.0-1~ubuntu.24.04~noble amd64
docker-ce/noble 5:29.3.1-1~ubuntu.24.04~noble amd64
...

Install a specific version by adding =<VERSION> after the package name.

For example, set a variable from the version list and then install it:

Terminal
DOCKER_VERSION="<VERSION>"
sudo apt install docker-ce=$DOCKER_VERSION docker-ce-cli=$DOCKER_VERSION containerd.io docker-buildx-plugin docker-compose-plugin

Replace <VERSION> with the exact version string returned by apt list --all-versions docker-ce.

Verify the Docker Installation

On most Ubuntu systems, the Docker service starts automatically after installation. If it does not, start it manually:

Terminal
sudo systemctl start docker

Check the service status:

Terminal
sudo systemctl status docker

The output will look something like this:

output
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled)
   Active: active (running)
...

You can also confirm that the client and daemon are responding:

Terminal
sudo docker version

To verify that Docker can pull and run containers correctly, run the test image:

Terminal
sudo docker run hello-world

If the image is not found locally, Docker will download it from Docker Hub, run the container, print a “Hello from Docker” message, and exit.

Docker Hello World

The container stops after printing the message because it has no long-running process.

Run Docker Commands Without sudo

By default, only root and a user with sudo privileges can run Docker commands.

Warning
Membership in the docker group grants root-level privileges. On shared systems, continue using sudo or configure Docker rootless mode instead.

To allow a non-root user to execute Docker commands, add the user to the docker group:

Terminal
sudo usermod -aG docker $USER

$USER is an environment variable that holds the currently logged-in username. If you want to execute commands with another user, replace $USER with that username.

Run newgrp docker or log out and log back in for the group membership changes to take effect.

After that, you can rerun the test container without sudo :

Terminal
docker run hello-world
Info
By default, Docker pulls images from Docker Hub. It is a cloud-based registry service that stores Docker images in public or private repositories.

Docker Compose

The docker-compose-plugin package installed in Step 4 provides Docker Compose , so there is no need to install Compose separately. Confirm that the plugin is available:

Terminal
docker compose version
output
Docker Compose version v5.3.1

Compose is invoked as docker compose, with a space. The old standalone docker-compose binary is deprecated and should not be used on new installations.

Updating Docker

When a new Docker version is released, update it using standard system commands:

Terminal
sudo apt update
sudo apt upgrade

To prevent only the Docker Engine package from being upgraded, mark docker-ce as held:

Terminal
sudo apt-mark hold docker-ce

Uninstalling Docker

Warning
The cleanup commands below permanently delete all Docker containers, images, volumes, networks, and local data. Skip them if you want to keep Docker data for a later installation.

If you want a clean removal, stop all running containers and remove all containers, images, volumes, and networks :

Terminal
docker container ls -aq | xargs -r docker container stop
docker system prune -a --volumes -f

Remove Docker packages:

Terminal
sudo apt purge docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo apt autoremove

To completely remove Docker data from your system, delete the directories that were created during the installation process:

Terminal
sudo rm -rf /var/lib/{docker,containerd}

Finally, remove the Docker repository configuration and signing key:

Terminal
sudo rm -f /etc/apt/sources.list.d/docker.sources /etc/apt/keyrings/docker.asc

Troubleshooting

Permission denied while trying to connect to the Docker daemon socket
Your user is not yet in the docker group, or the group membership has not taken effect. Run sudo usermod -aG docker $USER, then log out and back in (or run newgrp docker).

Cannot connect to the Docker daemon. Is the daemon running?
The Docker service is not running. Start it with sudo systemctl start docker and check its status with sudo systemctl status docker.

Package ‘docker-ce’ has no installation candidate
The Docker repository was not added correctly. Re-run Steps 2 and 3, then run sudo apt update before installing.

FAQ

What is the difference between docker.io and docker-ce?
docker.io is the Docker package that Ubuntu maintains in its own repositories, and it usually lags several releases behind. docker-ce is the official package from Docker, published as soon as a new version is released. Both provide Docker Engine; this guide installs docker-ce.

Does this guide install Docker Desktop?
No. This guide installs Docker Engine, which runs containers directly on your system. Docker Desktop is a separate product that bundles Docker Engine with a graphical interface inside a virtual machine and is aimed at development workstations. On servers, Docker Engine is what you want.

Conclusion

Installing Docker from the official repository ensures you always have access to the latest stable releases and security updates. For post-install steps such as configuring log drivers or setting up rootless mode, see the official post-install guide . When you are ready to build your own images, start with our Dockerfile guide .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page