How to Install Docker Container Engine on Ubuntu 24.04
02 Apr, 2026
Introduction
Docker is a containerization platform that packages software into standardized units called containers. Each container includes everything the software needs to run, including code, system tools, libraries, and settings. Unlike traditional virtual machines, containers share the host operating system kernel, making them lightweight and faster to start. Developers use Docker to build, ship, and run applications consistently across different environments, from local development machines to production servers.
This guide shows you how to install Docker on Ubuntu 24.04.
Prerequisites
Before you start:
- Deploy an Ubuntu 24.04 server or workstation.
- SSH to your server using PuTTY for Windows or Open SSH for Linux and Mac OS.
- Create a non-root user with sudo privileges.
Update Package Information Index
Refresh your system's package list to ensure you get the latest available versions.
$ sudo apt update
Install Prerequisite Packages
Docker requires several system packages to add repositories and handle secure transfers. Install these dependencies before proceeding with the Docker install.
-
Install
apt-transport-https, a package that allows apt to fetch packages over HTTPS.console$ sudo apt install -y apt-transport-https -
Install
ca-certificates, which contains trusted certificate authorities for secure connections.console$ sudo apt install -y ca-certificates -
Install
curl, a command-line tool for transferring data from servers.console$ sudo apt install -y curl -
Install
gnupg, a free implementation of the OpenPGP standard for secure key management.console$ sudo apt install -y gnupg -
Install
lsb-release, a package that provides Linux Standard Base release information.console$ sudo apt install -y lsb-release
Add Docker's Official GPG Key
Docker signs its packages with a GPG (GNU Privacy Guard) key. Adding this key to your system allows apt to verify the authenticity of Docker packages before installing them.
-
Download Docker's official GPG key using curl.
console$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc -
Set the correct permissions for the GPG key file.
console$ sudo chmod a+r /etc/apt/keyrings/docker.asc
Add Docker Repository
The Docker repository is not included in Ubuntu's default package sources. Add this repository to your system so apt can locate and install Docker packages.
-
Add the Docker repository to your apt sources list.
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 information index to include the newly added Docker repository.
console$ sudo apt update
Install Docker Engine
With the repository configured, you can now install Docker Engine and its core components. The Docker Engine is the underlying container runtime that builds and runs containers.
-
Install Docker Engine, the core daemon that manages containers.
console$ sudo apt install -y docker-ce -
Install Docker CLI, the command-line tool that communicates with the Docker daemon.
console$ sudo apt install -y docker-ce-cli -
Install Containerd, a container runtime that Docker uses to run containers.
console$ sudo apt install -y containerd.io -
Install Docker Buildx, a plugin for building container images with advanced features.
console$ sudo apt install -y docker-buildx-plugin -
Install Docker Compose, a tool for defining and running multi-container applications.
console$ sudo apt install -y docker-compose-plugin
Manage Docker Service
Docker runs as a system service on Ubuntu under the name docker. You can manage this service using specific commands to start, stop, restart, and check the Docker status. These commands ensure your Docker installation runs smoothly and make maintenance easier on your system.
Check Docker Service Status
$ sudo systemctl status docker
Output:
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Mon 2025-03-10 14:23:45 UTC; 2min 15s ago
Main PID: 12345 (dockerd)
Tasks: 8
Memory: 42.1M
CPU: 1.234s
CGroup: /system.slice/docker.service
└─12345 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Press Ctrl + C.
Start Docker Service
$ sudo systemctl start docker
Stop Docker Service
$ sudo systemctl stop docker
Restart Docker Service
$ sudo systemctl restart docker
Enable Docker to Start on Boot
$ sudo systemctl enable docker
Output:
Synchronizing state of docker.service with SysV service script with /usr/lib/systemd/systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable docker
Verify Docker Installation
After installing Docker, verify that it works correctly by running a test container. The hello-world image downloads from Docker Hub and runs a container that prints a confirmation message.
-
Run the hello-world test container.
console$ sudo docker run hello-worldOutput:
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world c1ec31eb5944: Pull complete Digest: sha256:1408fec50309aee4d0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f Status: Downloaded newer image for hello-world:latest 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 which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: $ docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/
Manage Docker as a Non-Root User
By default, only users with sudo privileges can run Docker commands. Adding your non-root user to the docker group eliminates the need to prefix every Docker command with sudo.
-
Add your non-root user to the docker group.
console$ sudo usermod -aG docker $USER -
Log out and log back in for the group changes to take effect.
console$ exit -
Verify that your user can run Docker commands without sudo after logging back in, .
console$ docker run hello-worldOutput:
Hello from Docker! This message shows that your installation appears to be working correctly.
Pull a Container Image
Docker Hub hosts thousands of pre-built container images. Pulling an image downloads it to your local system so you can run containers without an internet connection.
-
Pull the Ubuntu container image from Docker Hub.
console$ docker pull ubuntu:22.04Output:
22.04: Pulling from library/ubuntu 5e0b4c7e7a5f: Pull complete Digest: sha256:8dce6eb9d8b7e8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b8b Status: Downloaded newer image for ubuntu:22.04 docker.io/library/ubuntu:22.04 -
List all downloaded images on your system.
console$ docker imagesOutput:
REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu 22.04 a1234567890b 2 weeks ago 77.9MB hello-world latest b9876543210c 5 weeks ago 9.14kB
Run a Container Interactively
Running a container interactively gives you direct access to the container's shell. This approach helps you test commands and explore containerized environments.
-
Run an Ubuntu container with an interactive terminal session.
console$ docker run -it ubuntu:22.04 /bin/bashOutput:
root@a1b2c3d4e5f6:/#Inside the container, you can run any Linux command. The container is isolated from your host system.
-
Update the package list inside the container.
consoleroot@a1b2c3d4e5f6:/# apt updateOutput:
Get:1 http://archive.ubuntu.com/ubuntu jammy InRelease [270 kB] Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB] ... Reading package lists... Done -
Exit the container by typing
exitor pressing Ctrl + D.consoleroot@a1b2c3d4e5f6:/# exitOutput:
exit
Conclusion
In this guide, you installed Docker Engine on Ubuntu 24.04 by adding Docker's official repository and using apt to install the core components. You managed the Docker systemd service, verified your install with the hello-world container, configured non-root user access, pulled images from Docker Hub, and ran interactive containers. Now that you have Docker running, consider containerizing your own application by writing a Dockerfile or explore Docker Compose to manage multi-container applications like web servers with databases.