How To

Install Docker on Ubuntu 24.04: Repository, Compose, and Non-Root

Docker is an open-source containerization platform that packages an application and everything it depends on into a single container. That container runs identically across development machines, test environments, and production servers.

This guide shows how to install Docker on Ubuntu 24.04 (Noble Numbat) from the official Docker repository — not the docker.io package Ubuntu ships, which typically lags several major versions behind. By the end you will have Docker Engine, Docker Compose, and a user configured to run Docker without sudo.

Prerequisites: A 64-bit Ubuntu 24.04 system with sudo access and an active internet connection. Note: Docker manages its own iptables rules, and published container ports can bypass UFW firewall rules. Review Docker’s firewall documentation before exposing services on shared or public networks.

Install Docker on Ubuntu 24.04 from the Official Repository

Remove any conflicting packages first:

bash<br>sudo apt remove docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc<br>

Install dependencies:

bash<br>sudo apt update &amp;&amp; sudo apt install ca-certificates curl<br>

Import Docker’s GPG signing key:

bash<br>sudo install -m 0755 -d /etc/apt/keyrings<br>sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc<br>sudo chmod a+r /etc/apt/keyrings/docker.asc

The chmod a+r call makes the key file readable by the _apt system user that apt uses internally to verify packages during download.

Add the Docker repository using the DEB822 .sources format. The ${UBUNTU_CODENAME:-$VERSION_CODENAME} expression reads the release codename from /etc/os-release. On Ubuntu 24.04 this returns noble:

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

Install Docker Engine:

bash<br>sudo apt update<br>sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin<br>

All five packages are needed: docker-ce (daemon), docker-ce-cli (client), containerd.io (container runtime), docker-buildx-plugin (multi-platform builds), and docker-compose-plugin (the docker compose subcommand).

To pin a specific version, list available options first and install both the daemon and CLI at the same version. They must match because each version pair defines a specific API contract:

bash<br>apt list --all-versions docker-ce 2>/dev/null | awk 'NR>1 {print $2}'<br>DOCKER_VERSION="5:29.4.0-1~ubuntu.24.04~noble"<br>sudo apt install docker-ce=$DOCKER_VERSION docker-ce-cli=$DOCKER_VERSION containerd.io docker-buildx-plugin docker-compose-plugin<br>

Verify Docker, Set Up Non-Root Access, and Use Docker Compose
Docker starts automatically after installation on most Ubuntu systems. If it does not:

bash<br>sudo systemctl start docker &amp;&amp; sudo systemctl status docker

Pull and run the test container:

bash<br>sudo docker run hello-world

Docker downloads the hello-world image from Docker Hub, runs it in an isolated container, prints a confirmation, and exits.

Remove the sudo requirement. Add your user to the docker group:

bash<br>sudo usermod -aG docker $USER<br>newgrp docker

Log out and back in to apply the group change to all sessions.

Security note: The docker group grants effective root-level access to the host because members can mount any host path into a container. On shared systems, continue using sudo or configure Docker rootless mode.

Docker Compose V2 is built in as a plugin no separate install needed. Use docker compose with a space. The older standalone docker-compose V1 binary is deprecated and should not be used on new setups:

bash<br>docker compose version<br>Update, Hold, and Uninstall Docker

Update Docker with standard apt commands:

bash<br>sudo apt update &amp;&amp; sudo apt upgrade

To prevent automatic version changes important on Kubernetes nodes and production workloads that depend on a specific Docker version:

bash<br>sudo apt-mark hold docker-ce


To uninstall cleanly, stop and remove all containers and stored data before removing packages. The -r flag in xargs prevents errors when no containers are running:

bash

docker container ls -aq | xargs -r docker container stop<br>docker system prune -a --volumes -f<br>sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras<br>sudo apt autoremove<br>sudo rm -rf /var/lib/{docker,containerd}<br>sudo rm -f /etc/apt/sources.list.d/docker.sources /etc/apt/keyrings/docker.asc<br>The last line removes the repository configuration and signing key, leaving a clean slate if you reinstall later.

Docker Engine and Docker Compose are now running on Ubuntu 24.04. For next steps, build images with a Dockerfile, configure log drivers, or set up rootless mode for improved security isolation. Leave a comment below if you run into any issues.

Cyber Defence

Recent Posts

Change User Password in Ubuntu: Command Line and GNOME GUI

Using a strong, unique password for every account is one of the most effective security…

6 minutes ago

Enable and Disable the Root Account in Ubuntu: Full Guide

Ubuntu locks the root account by default. New users often wonder what the root password…

11 minutes ago

Configure Netplan on Ubuntu: DHCP, Static IP, Wi-Fi, and Bridges

Since Ubuntu 17.10, networking is configured with Netplan rather than the older /etc/network/interfaces file. You write a…

16 minutes ago

update-alternatives on Ubuntu: Manage Default Program Links

When two or more installed programs provide the same command name, the system needs a…

6 hours ago

Install Docker on Ubuntu 26.04: Official Repository Setup Guide

Install Docker on Ubuntu 26.04: Official Repository Setup GuideDocker is an open-source container platform that…

2 days ago

Install Asterisk on Ubuntu 18.04: Source Build and Secure Config

Asterisk is the most widely deployed open-source PBX (Private Branch Exchange) platform in the world. It…

3 days ago