Install Docker on Ubuntu 24.04 (Step by Step)
Install Docker Engine on Ubuntu 24.04 from the official repo, run containers without sudo, and add Docker Compose. Avoid the universe and Snap pitfalls.
Docker is the standard way to package and run applications as portable containers, and on Ubuntu 24.04 the only install method worth trusting is Docker's own apt repository. The version in Ubuntu's universe repo lags behind, and the Snap package is a frequent source of permission and storage headaches. This guide does it the right way: Docker Engine from the official repo, your user able to run Docker without sudo, and Docker Compose included.
By the end you will have a clean, repeatable container host: GPG key and repository configured, the engine running and enabled at boot, and a verified first container. These are the same fundamentals that underpin cloud-native workloads on a private cloud.
Prerequisites
You need Ubuntu 24.04 LTS (codename noble), a user with sudo privileges, and outbound internet access to download.docker.com. If you previously installed Docker from Ubuntu's repo or the Snap, remove it first to avoid conflicts.
Step 1: Remove old or conflicting packages
Clear out any distro Docker packages so they do not shadow the official engine:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 \
podman-docker containerd runc; do
sudo apt remove -y $pkg
doneIf you have the Snap version, remove it too:
sudo snap remove docker 2>/dev/null || trueStep 2: Add Docker's official GPG key
Install the prerequisites and fetch Docker's signing key into a dedicated keyring:
sudo apt update
sudo apt install -y 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.ascStep 3: Add the Docker apt repository
Register the repo for your architecture and Ubuntu codename. This one-liner resolves the codename automatically:
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 updateStep 4: Install Docker Engine and Compose
Install the engine, CLI, containerd, the Buildx plugin, and the Compose v2 plugin in one go:
sudo apt install -y docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-pluginThe service starts and is enabled at boot automatically. Confirm it:
sudo systemctl status docker --no-pager
docker --version
docker compose versionStep 5: Run Docker without sudo
Add your user to the docker group so you do not need sudo for every command. Note the security implication: the docker group is root-equivalent.
sudo usermod -aG docker $USER
newgrp dockerGroup membership applies to new sessions; newgrp activates it in the current shell.
Step 6: Verify with the hello-world container
Pull and run the test image. Docker downloads it, runs it, and prints a confirmation message:
docker run hello-worldA successful run reports:
Hello from Docker!
This message shows that your installation appears to be working correctly.Run something more useful โ an Nginx web server published on port 8080:
docker run -d --name web -p 8080:80 nginx:stable
curl -I http://localhost:8080Step 7: A first Docker Compose file
Compose defines multi-container apps declaratively. Create compose.yaml:
cat > compose.yaml <<'EOF'
services:
web:
image: nginx:stable
ports:
- "8080:80"
restart: unless-stopped
EOFBring the stack up in the background, check status, and tear it down:
docker compose up -d
docker compose ps
docker compose downTroubleshooting and pitfalls
- โpermission denied while trying to connect to the Docker daemon socketโ โ you are not yet in the
dockergroup in this session; runnewgrp dockeror re-login. - โdocker compose: command not foundโ โ you installed the legacy
docker-compose; use the v2 plugin invoked asdocker compose(space, not hyphen). - Repo errors on apt update โ the codename in
docker.listdoes not match; for 24.04 it must benoble. - Snap leftovers โ a lingering Snap Docker can hijack the
dockercommand; remove it and open a fresh shell.
Where to go next
Docker is one container model; for persistent, VM-like environments compare it with LXD/LXC system containers. To give containers direct LAN addresses instead of NAT, set up Linux bridge networking.
Conclusion
You now have Docker Engine installed the supported way, sudo-less operation, and Compose for multi-container apps โ a clean foundation for cloud-native workloads. Running containers at scale eventually means orchestration, networking, persistent storage, and security across many hosts, which is exactly where a managed platform earns its keep. clouditiv runs a sovereign, ISO 27001 / BSI C5 private cloud on Ubuntu 24.04 + OpenStack 2025.2 with your data in Germany, giving your containers a resilient home without you operating the substrate. See our on-premise cloud solution.