How to install Docker on Ubuntu 24.04 LTS

There are many methods to install Docker on Ubuntu 24.04 LTS. This tutorial teaches you how to install Docker on Ubuntu 24.04 LTS through the apt repository.

Docker is a platform that offers tools to develop, run, and ship applications in isolated containers. The code and its dependencies are packaged in a virtual container that can run on Windows, Linux, and MacOS. This approach guarantees the standardization of software packages. You don’t have to rely on the host system libraries and settings to run your application because everything is packed within the container.

This tutorial teaches you how to install Docker on Ubuntu 24.04 LTS through the apt repository.

Step 1: Update Ubuntu 24.04 LTS

Before following the Docker installation steps, updating packages on Ubuntu 24.04 LTS is a good practice. This ensures your packages are updated with the latest security upgrades, bug fixes, and features.

To update Ubuntu 24.04 LTS type:

sudo apt update

Step 2: Install ca-certificates

Digital certificates verify the identity of a website or an organization. The ca-certificates package provides updated certificates. In our case, this package is required to verify the identity of the Docker package source.

To install ca-certificates on Ubuntu 24.04 LTS type:

sudo apt install ca-certificates

Step 3: Install curl on Ubuntu 24.04 LTS

curl is a command line utility that retrieves files on the internet. It supports protocols such as HTTP, FTP, SMTP, TELNET, POP3, and many others. This article uses curl to retrieve the public signing key for the Docker package.

To install curl on Ubuntu 24.04 LTS type:

sudo apt install curl

Step 4: Create the directory for the Docker package keyring

You need to store the keyring for the package source so it passes the apt-secure verification. To create the directory where keys for Ubuntu packages can be stored type:

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

The install command in Linux creates the directories and subdirectories with the -d option. It also sets the permissions with the -m option.

Step 5: Setup the signing key for the Docker apt repository

For apt to trust the package you need to download its public signing key and place it inside the /etc/apt/keyrings directory. Later you have to call the Docker’s package signing key with the signed-by attribute inside the apt repository file.

To download the keyring for the Docker package on Ubuntu 24.04 LTS type:

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

The -o option in the above curl command specifies the output path for the downloaded file.

To add the reading permission to the docker.asc file type:

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

Step 6: Create the Docker apt repository file

To find the architecture of your Ubuntu host type:

dpkg --print-architecture

Create an empty file named docker.list inside the /etc/apt/source.list.d directory.

sudo nano /etc/apt/source.list.d/docker.list 

To create the Docker apt repository copy and paste the following to /etc/apt/sources.list.d/docker.list file. In case your Ubuntu is running on a different architecture make sure to replace amd64 in the following string.

"deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu noble stable"
Docker apt repository file

Hit Ctrl O to write changes with the Nano text editor. Then hit Ctrl X to quit the Nano text editor.

In the above piece of code:

  • arch specifies the architecture of the host.
  • signed-by specifies the public key file for the apt-secure check.
  • noble specifies the codename for Ubuntu 24.04 LTS.
  • stable specifies the source type.

Then update the package index for the changes to take effect:

sudo apt update

Step 7: Install Docker on Ubuntu 24.04 LTS

To install the latest version of Docker on Ubuntu 24.04 LTS through the apt repository type:

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

how to install docker on ubuntu 24.04 lts
Docker installation on Ubuntu 24.04 LTS

Type Y and hit Enter.

Step 8: Run your first container with Docker on Ubuntu 24.04 LTS

To start Docker as a service on Ubuntu 24.04 LTS type:

sudo service docker start

To run a test container with Docker type:

docker run hello-world
hello-world container in Docker

Final thoughts

You learned how to install Docker on Ubuntu 24.04 LTS through easy-to-follow and clear steps. Although the Docker installation shared in this article is achieved through the apt repository there are many other methods.

Leave comment

Your email address will not be published. Required fields are marked with *.