How to Install Docker on Ubuntu 24.04

Complete step-by-step guide for Ubuntu 24.04, 22.04, and 20.04 LTS. Install Docker CE from the official repository - 6 commands, under 5 minutes.

TL;DR
  • Covers Ubuntu 24.04 LTS, 22.04 LTS, and 20.04 LTS
  • Time to complete: ~5 minutes on a fresh server
  • Difficulty: Beginner-Intermediate (sudo access required)
  • Short answer: Install Docker CE on Ubuntu with 6 commands via the official Docker repository

What Is Docker and Why Run It on a Ubuntu VPS?

Docker is an open-source containerization platform that packages applications and their dependencies into isolated, portable containers. Instead of installing runtimes, libraries, and config files directly onto a server, Docker lets you ship a self-contained image that runs identically on any Linux host. A container spins up in milliseconds, consumes far fewer resources than a virtual machine, and eliminates the classic "works on my machine" problem that plagues distributed teams.

Running Docker on a Ubuntu VPS is the standard setup for modern backend deployments in 2026. Ubuntu LTS releases offer the longest support windows (5 years), broad community documentation, and first-class support from Docker upstream. On a FastNode NVMe VPS, Docker images pull faster, container starts are snappier, and disk-heavy builds - think multi-stage Dockerfile compilations - complete significantly quicker thanks to NVMe's parallelised I/O queues running at up to 3,500 MB/s sequential read. Whether you're shipping a Node.js API, a PostgreSQL instance, or a full Docker Compose stack, this guide gets you from a fresh Ubuntu server to a running container in under 5 minutes.

Prerequisites Before You Install Docker on Ubuntu

Before running any commands, confirm the following requirements are met:

  • Ubuntu version: 24.04 LTS (Noble), 22.04 LTS (Jammy), or 20.04 LTS (Focal) - this guide covers all three
  • Root or sudo access: All install commands require elevated privileges
  • Terminal access: SSH into your server or use a web-based console
  • Internet connectivity: The server must reach apt and Docker's CDN to download packages
  • Minimum specs: 1 vCPU, 512 MB RAM, 4 GB disk (1 GB RAM recommended for running containers)
  • Architecture: x86_64 (amd64) or arm64 - both are supported by Docker CE

Install Docker on Ubuntu - Step-by-Step (2026)

The official Docker installation method uses Docker's own apt repository, which always provides the latest stable Docker CE release. Avoid installing docker.io from Ubuntu's default repositories - it lags behind upstream and lacks the Docker Engine features you'll need.

Update apt and refresh package index

Start with a clean package index. This ensures apt resolves to the latest package metadata and prevents version conflicts during install.

sudo apt-get update

Install required dependencies

These packages allow apt to use repositories over HTTPS and verify package signatures. ca-certificates and curl are needed to download the Docker GPG key.

sudo apt-get install -y \
  ca-certificates \
  curl \
  gnupg \
  lsb-release

Add Docker's official GPG key

Docker signs all packages with a GPG key. Adding this key to apt's keyring lets the package manager verify that downloads are authentic and haven't been tampered with.

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
  | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Add the Docker apt repository

This adds Docker's stable channel to your apt sources. The $(. /etc/os-release && echo "$VERSION_CODENAME") substitution automatically detects your Ubuntu release - this works correctly on 20.04, 22.04, and 24.04.

echo \
  "deb [arch=$(dpkg --print-architecture) \
  signed-by=/etc/apt/keyrings/docker.gpg] \
  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

Install Docker Engine, CLI, and containerd

This installs the full Docker CE stack: the Docker Engine daemon (dockerd), the CLI client (docker), containerd runtime, and the Compose plugin. Installing all four in one command ensures version compatibility.

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

Verify the installation

Run the official hello-world image to confirm Docker is installed correctly. Docker will pull the image from Docker Hub, create a container, print a confirmation message, and exit.

sudo docker run hello-world
output
Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image.
 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

Run Docker on FastNode - Deploy a VPS in Seconds

NVMe-backed Ubuntu servers, ready in under 30 seconds. Root access, Docker CE, full API & CLI included.

Start Free Trial

Post-Install Configuration - Add User, Enable on Boot, Test

Docker is running, but three quick configuration steps will save you from running sudo before every docker command and ensure Docker starts automatically after a reboot.

Add Your User to the Docker Group

By default, the Docker daemon runs as root and requires sudo. Adding your user to the docker group grants non-root access to the Docker socket. Replace $USER with your actual username if running as root.

sudo usermod -aG docker $USER
newgrp docker

The newgrp docker command activates the group membership in your current session. For a fresh login, close and reopen your SSH session instead - the group change will persist.

Enable Docker to Start on Boot

On Ubuntu, Docker should be enabled as a systemd service so it restarts automatically after a server reboot. This is critical for production deployments and blockchain node operators who need continuous uptime.

sudo systemctl enable docker
sudo systemctl enable containerd

Confirm the service is active and running without errors:

sudo systemctl status docker
output
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Mon 2026-04-07 10:22:01 UTC; 2min ago
     Docs: https://docs.docker.com
   Main PID: 1234 (dockerd)

Test With a Sample nginx Container

Pull and run a real-world container to validate your setup. This command runs nginx in detached mode (-d), maps host port 80 to container port 80, and names it test-nginx:

docker run -d --name test-nginx -p 80:80 nginx:alpine

Verify it's running:

docker ps
output
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                NAMES
a3f8b2c91d44   nginx:alpine   "/docker-entrypoint.…"   5 seconds ago   Up 4 seconds   0.0.0.0:80->80/tcp   test-nginx

Clean up the test container when done:

docker stop test-nginx && docker rm test-nginx

Common Docker Install Errors on Ubuntu - Fixes

Here's the thing: most Docker installation failures trace back to one of three root causes - stale package locks, permission issues, or leftover packages from a previous install. Here are the fixes.

ERROR: permission denied while trying to connect to the Docker daemon socket

Your user isn't in the docker group, or the group change hasn't been applied to your current session.

Fix:

sudo usermod -aG docker $USER
# Then log out and log back in, or run:
newgrp docker

ERROR: E: Could not get lock /var/lib/dpkg/lock-frontend

Another apt process is running - usually an unattended-upgrades background job. Wait 30-60 seconds and retry. If it persists, remove the lock file (only if you're certain no install is in progress).

Fix:

# Wait for the lock to clear, then:
sudo killall apt apt-get
sudo rm /var/lib/dpkg/lock-frontend
sudo rm /var/lib/dpkg/lock
sudo dpkg --configure -a
sudo apt-get update

ERROR: Conflicting packages - docker.io, docker-doc, or containerd

Old Docker packages from Ubuntu's default repos (docker.io, docker-doc, docker-compose, podman-docker) conflict with Docker CE. Remove them first before adding the Docker repo.

Fix:

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

# Then re-run the installation steps from Step 1

Quick sanity check: After a successful install, docker --version should return something like Docker version 27.x.x, build xxxxxxx. If the command isn't found, the install didn't complete - re-run from Step 1 after purging old packages.

Next Steps - Docker Compose, First App, and Deploying on FastNode

Docker is installed and verified. Here's where to go next - from orchestrating multi-container apps to deploying your first production stack on a FastNode VPS with NVMe-backed storage and sub-30-second provisioning.

Install Docker Compose

Docker Compose lets you define and run multi-container applications with a single docker compose up command. Already included as a plugin if you followed this guide.

docker compose version
View Docker support →

Deploy Your First App

Run a full-stack app - Node.js API, PostgreSQL, and Nginx reverse proxy - using Docker Compose on your FastNode VPS. One file, three containers, production-ready in minutes.

docker compose up -d
Explore developer tools →

FastNode One-Click Docker VPS

Skip the manual install entirely. FastNode's one-click Docker app provisions an Ubuntu 24.04 VPS with Docker CE pre-installed and ready to use - server live in under 30 seconds.

Deploy from $5/mo →

Frequently Asked Questions About Docker on Ubuntu

Straight answers to the most common questions from the Docker Ubuntu install search cluster.

Install Docker on Ubuntu 24.04 by adding the official Docker apt repository and installing docker-ce. The six-step process: (1) sudo apt-get update, (2) install ca-certificates curl gnupg, (3) add Docker's GPG key to /etc/apt/keyrings/docker.gpg, (4) add the Docker stable repo to apt sources, (5) sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin, (6) verify with sudo docker run hello-world. Do not install from Ubuntu's default repos - docker.io is outdated and missing key features.
The fastest way to run Docker on a VPS is to deploy a FastNode VPS with the one-click Docker app - the server provisions in under 30 seconds with Docker CE pre-installed. If you're installing manually on an existing Ubuntu VPS, the six steps above complete in under 5 minutes. On an NVMe-backed VPS, Docker image pulls and container starts are noticeably faster than on SATA-SSD servers due to NVMe's parallelised I/O queues.
Yes. Docker CE fully supports Ubuntu 22.04 LTS (Jammy Jellyfish). The installation steps in this guide work on Ubuntu 20.04, 22.04, and 24.04 without modification - the $(. /etc/os-release && echo "$VERSION_CODENAME") substitution in Step 4 automatically selects the correct repository for your Ubuntu release. Ubuntu 22.04 will be supported until April 2027 (standard) or April 2032 (extended).
Yes, you need sudo (or root) access to install Docker - the daemon runs as root and the installation writes to system directories. After install, you can add your user to the docker group (sudo usermod -aG docker $USER) to run docker commands without sudo in day-to-day use. Note: the docker group grants root-equivalent privileges - only add trusted users.
Run sudo docker run hello-world immediately after install. If Docker is working correctly, this command pulls the hello-world image from Docker Hub, runs a container, and prints a success message. You can also check the installed version with docker --version (should return Docker version 27.x.x or later) and confirm the daemon is active with sudo systemctl status docker.

Launch Your Docker-Ready Ubuntu VPS for $5/mo

NVMe storage, root access, 30-second deploy - everything Docker needs. Skip the manual install with FastNode's one-click Docker app. Plans from $5/mo with a 30-day money-back guarantee.

30s Deploy
NVMe Storage
Docker Ready
30-Day Refund