Platform: Ubuntu Server 24.04.4 LTS — Intel / AMD (x86_64)

This guide walks you through installing Docker Engine, Docker Compose v2, and Docker Buildx on Ubuntu Server 24.04.4 LTS (Intel / AMD). It also configures Docker to start automatically at boot, so your containers are always ready after a reboot.

Overview

By the end of this guide, you will have the following installed and running:

  • Docker Engine
  • Docker Compose v2
  • Docker Buildx
  • Automatic Docker startup on boot

Step 1 — Update Ubuntu

Start by updating the package list and upgrading any outdated packages on your system.

sudo apt update
sudo apt upgrade -y

Step 2 — Install Required Dependencies

Install the packages needed to securely download and add Docker’s official repository.

sudo apt install -y ca-certificates curl gnupg

Step 3 — Create the Docker Keyring Directory

Create the directory where Docker’s GPG key will be stored. This directory is used to verify the authenticity of packages downloaded from Docker’s repository.

sudo install -m 0755 -d /etc/apt/keyrings

Step 4 — Add Docker’s Official GPG Key

Download Docker’s official GPG key and save it to the keyring directory you just created.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Then set the correct file permissions so the key is readable by the system:

sudo chmod a+r /etc/apt/keyrings/docker.gpg

Step 5 — Add the Docker Repository

Add Docker’s official APT repository to your system’s package sources. This tells apt where to find Docker packages.

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

Step 6 — Update the Package Index

Refresh the package list so your system recognizes the newly added Docker repository.

sudo apt update

Step 7 — Install Docker Engine and Components

Install Docker Engine along with all required plugins and tools.

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

Here is what each component does:

PackageDescription
docker-ceDocker Engine — the core service that runs containers
docker-ce-cliDocker command-line interface for running Docker commands
containerd.ioLow-level container runtime that Docker depends on
docker-buildx-pluginAdvanced image build tool with multi-platform support
docker-compose-pluginDocker Compose v2 — runs multi-container applications

Step 8 — Enable Docker to Start Automatically

Enable the Docker service so it starts automatically every time the server boots, then start it now.

sudo systemctl enable docker
sudo systemctl start docker

Verify that Docker is running:

systemctl status docker

You should see active (running) in the output. Press Q to exit the status view.

Step 9 — Verify the Installation

Confirm that Docker Engine and Docker Compose were installed correctly by checking their versions.

Check the Docker version:

docker --version

Expected output:

Docker version 26.x.x, build xxxxxxx

Check the Docker Compose version:

docker compose version

Expected output:

Docker Compose version v2.x.x

Step 10 — Test the Docker Installation

Run the official Docker test container to confirm everything is working end-to-end.

sudo docker run hello-world

If Docker is installed correctly, you will see a message that starts with:

Hello from Docker!

Step 11 — (Optional) Run Docker Without sudo

By default, Docker requires sudo to run commands. You can add your user to the docker group to avoid typing sudo every time.

sudo usermod -aG docker $USER

Log out and log back in (or reboot the server) for the group change to take effect. Then test it:

docker ps

If no error appears, you can now run Docker commands without sudo.

Example — Test Docker Compose

This is a quick end-to-end test to confirm Docker Compose is working correctly. It spins up an Nginx web server using a simple Compose file.

1. Create a Test Directory

mkdir ~/docker-test
cd ~/docker-test

2. Create the Compose File

nano docker-compose.yml

Paste the following content into the file:

services:
  nginx:
    image: nginx:latest
    ports:
      - "8080:80"

Save and exit: press Ctrl+X, then Y, then Enter.

3. Start the Container

docker compose up -d

4. Verify the Container Is Running

docker ps

You should see the nginx container listed with a status of Up.

5. Open in Your Browser

Navigate to the following URL, replacing SERVER-IP with your server’s actual IP address:

http://SERVER-IP:8080

You should see the default Nginx welcome page. This confirms Docker Compose is running correctly.

6. Stop the Container

docker compose down

Useful Docker Commands

Here are some everyday Docker commands you will use often:

CommandDescription
docker psList all currently running containers
docker ps -aList all containers, including stopped ones
docker logs CONTAINER_NAMEView the logs for a specific container
docker stop CONTAINER_NAMEStop a running container
docker rm CONTAINER_NAMERemove a stopped container
docker imagesList all locally downloaded Docker images
docker pull IMAGE_NAMEDownload a Docker image from Docker Hub

Recommended Tools for Docker Servers

Once Docker is up and running, these tools are highly recommended for managing your server environment:

ToolPurpose
PortainerWeb-based UI for managing Docker containers, images, and volumes
Nginx Proxy ManagerEasy reverse proxy management with built-in SSL support
WatchtowerAutomatically keeps your running containers updated