How to Install Docker on Ubuntu 24.04

2026-09-11 38 Docker Guides
How to Install Docker on Ubuntu 24.04

Docker is a platform for running applications in isolated containers. Containers make it possible to quickly deploy web services, databases, control panels, and other applications without having to manually install all dependencies directly on the host system.

In this guide, we will install Docker Engine on Ubuntu 24.04 LTS using the official Docker repository.

Requirements

Before you begin, make sure you have:

  • a server running Ubuntu 24.04 LTS;

  • a root user or a user with sudo privileges;

  • an Internet connection;

  • SSH or console access to the server.

All commands below can be executed through SSH.

Step 1. Update the System

Before installing Docker, update the package index:

sudo apt update

If necessary, install available system updates:

sudo apt upgrade -y

Step 2. Install the Required Packages

Install ca-certificates and curl:

sudo apt install ca-certificates curl -y

Create a directory for APT repository keys:

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

Step 3. Add the Official Docker GPG Key

Download the official Docker GPG key:

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

Set the required permissions:

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

Step 4. Add the Docker Repository

Add the official Docker repository to Ubuntu:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the package index again:

sudo apt update

Docker will now be installed from the official Docker repository instead of the standard Ubuntu repository.

Step 5. Install Docker Engine

Install Docker Engine, Docker CLI, containerd, Docker Buildx, and Docker Compose:

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

Wait for the installation to complete.

Step 6. Verify the Docker Installation

Check the status of the Docker service:

sudo systemctl status docker

If Docker is running correctly, you should see:

active (running)

Press q to exit the status screen.

You can also check the installed Docker version:

docker --version

For example:

Docker version 28.x.x, build ...

The exact version number depends on the version currently available in the Docker repository.

Step 7. Run a Test Container

Docker provides a special hello-world image that can be used to verify that Docker Engine is working correctly.

Run:

sudo docker run hello-world

Docker will automatically download the image and start the container.

If Docker is installed correctly, you should see:

Hello from Docker!

This confirms that Docker Engine has been successfully installed and can run containers.

Run Docker Without sudo

By default, a regular user may need to use sudo when running Docker commands:

sudo docker ps

If you want to run Docker commands without sudo, add the current user to the docker group:

sudo usermod -aG docker $USER

Then log out of the SSH session:

exit

Connect to the server again.

You should now be able to run:

docker ps

without sudo.

Important: Membership in the docker group effectively grants privileged access to the system. Only add trusted users to this group.

Check Docker Compose

The docker-compose-plugin package installed earlier provides Docker Compose.

Check the installed version:

docker compose version

Modern versions of Docker use:

docker compose

instead of the older command:

docker-compose

For more information about Docker Compose installation and usage, see our “How to Install Docker Compose on Ubuntu 24.04” guide.

Enable Docker at System Startup

Docker is normally configured to start automatically with the operating system.

You can enable automatic startup with:

sudo systemctl enable docker

To enable Docker at startup and start the service immediately:

sudo systemctl enable --now docker

Essential Docker Commands

After installing Docker, the following commands can be useful.

Show running containers:

docker ps

Show all containers, including stopped ones:

docker ps -a

Show downloaded Docker images:

docker images

Download the Nginx image:

docker pull nginx

Run Nginx in a container and expose it on port 80:

docker run -d -p 80:80 nginx

Stop a container:

docker stop CONTAINER_ID

Remove a container:

docker rm CONTAINER_ID

Remove an image:

docker rmi IMAGE_ID

For a more complete list with practical examples, see our “Essential Docker Commands: Cheat Sheet with Examples” guide.

Example: Run Nginx in Docker

To test Docker with a real application, you can launch an Nginx web server:

docker run -d \
  --name nginx \
  --restart unless-stopped \
  -p 80:80 \
  nginx

Check that the container is running:

docker ps

If port 80 is accessible from the Internet, open the following address in your browser:

http://SERVER_IP_ADDRESS

You should see the default Nginx welcome page.

To stop the container:

docker stop nginx

To remove it:

docker rm nginx

How to Uninstall Docker from Ubuntu 24.04

If you no longer need Docker, remove the installed packages with:

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

You can then remove the official Docker repository and its GPG key:

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

Keep in mind that removing the Docker packages does not necessarily remove all containers, images, volumes, or other Docker data.

If you want to completely remove Docker data, check the contents of the following directories before deleting them:

/var/lib/docker
/var/lib/containerd

Deleting these directories will permanently remove the Docker data stored in them.

Conclusion

Docker on Ubuntu 24.04 makes it easy to deploy applications and services in isolated containers. Installing Docker from the official repository gives you access to current versions of Docker Engine, Docker Compose, and Docker Buildx.

After installation, you can verify that Docker is working by running:

docker run hello-world

For applications consisting of multiple containers, you can use:

docker compose

Docker is an excellent choice for VPS and dedicated servers used to host web applications, databases, reverse proxies, monitoring systems, control panels, and many other services.