How to Install Docker on Ubuntu 24.04

Docker is an open-source containerization platform that automates deploying, scaling, and managing applications in containers. Containers are lightweight and portable executable packages that contain all the necessary resources required to run an application. A container includes the application code, runtime, libraries, and dependencies that ensure consistency when running the application.
This article explains how to install Docker on an Ubuntu 24.04 server.
Prerequisites
Before you begin, have access to an Ubuntu 24.04 server as a non-root user with sudo privileges.
Install Docker
Install the packages required to add the Docker repository.
console$ sudo apt install ca-certificates curl -y
Create the keyrings directory that APT uses to store repository signing keys.
console$ sudo install -m 0755 -d /etc/apt/keyrings
Download the Docker GPG key to the keyrings directory.
console$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
Set read permissions on the key so APT can read it.
console$ sudo chmod a+r /etc/apt/keyrings/docker.asc
Add the Docker repository to your APT sources.
console$ 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
Update the package index.
console$ sudo apt update
Install Docker Engine and its plugins.
console$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
This command installs Docker Engine with the following components:
docker-ce: The Docker Engine community edition package.docker-ce-cli: The Docker command-line interface (CLI).containerd.io: A container runtime that manages the lifecycle of Docker containers.docker-buildx-plugin: Extends Docker's image-building capabilities for multi-platform builds.docker-compose-plugin: Manages multi-container Docker applications defined in YAML files.
View the installed Docker version on your server.
console$ sudo docker --version
Output:
Docker version 29.6.1, build 8900f1d
Manage the Docker System Service
Enable the Docker service to start automatically at boot.
console$ sudo systemctl enable docker
On Ubuntu, the package installer already enables this service, so the command confirms it is enabled.
View the Docker service status.
console$ sudo systemctl status docker
Verify that the output shows
active (running).Run the following command to stop Docker.
console$ sudo systemctl stop docker
Restart the Docker service.
console$ sudo systemctl restart docker
Add your non-root user to the
dockergroup to run Docker CLI commands without sudo privileges. Replacelinuxuserwith your actual username.console$ sudo usermod -aG docker linuxuser
Enable the new user group changes in your active session.
console$ newgrp docker
Conclusion
You have installed Docker and the Docker Compose plugin on an Ubuntu 24.04 server, verified that the service is running, and added your user to the docker group. For more information, refer to the official Docker documentation.