Cantech Knowledge Base

Your Go-To Hosting Resource

How to Install Docker on Ubuntu 24.04?

Introduction

Docker is an open source software platform that enables the creation, deployment and management of virtualized application containers across a shared operating system. It transformed software development and deployment through its introduction of a standardized method for packaging, distributing and running applications. It delivers its platform as a service (PaaS) offerings by employing OS-level virtualization to package software into units known as containers.

Originally designed for Linux, Docker has evolved to include expanded compatibility with non-Linux systems like Microsoft Windows and Apple OS X. Docker’s cross-platform functionality drives its extensive adoption across various computing environments such as on-premises data centers and public clouds including hybrid setups. Due to its strong integration with Linux distributions, docker ubuntu environments are widely used for container-based application deployment.

In this article, you will learn how to install docker on ubuntu 24.04

Prerequisites

  • An instance of Ubuntu 24. 04 with SSH access.
  • A sudo user configured on the server instance.
  • An active internet connection.

Installation of Docker

1. Update system and install dependencies

Log into the server and update the package index that is defined in /etc/apt/sources.list file and /etc/apt/sources.list.d/ directory.

sudo apt update

Some dependencies are required for the installation to progress well. So, run the command below to install them.

sudo apt install curl apt-transport-https ca-certificates software-properties-common

Now package lists are updated, and requisite software packages are present, next proceed to install Docker.

2. Install Docker

To install the most current version, you need to install it from the official Docker repository.

Download the Docker GPG key using the curl command below.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Then, add the Docker APT repository to the system. This command creates a docker.list repository file in the /etc/apt/sources.list.d directory.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the local package index to notify the system of the newly added repository.

sudo apt update

Then, install the Docker Community Edition as follows. In the below command, the -y option allows for non-interactive installation.

sudo apt install docker-ce -y

Sample output:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  containerd.io docker-ce-cli docker-ce-rootless-extras docker-scan-plugin
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras docker-scan-plugin
0 upgraded, X newly installed, 0 to remove and X not upgraded.
Need to get XX.X MB of archives.
After this operation, XXX MB of additional disk space will be used.

Check the installed Docker version on your server by running the following command:

sudo docker --version

Output:

Docker version 25.0.3, build 4debf41

3. Verify the Installation Status

The Docker service starts automatically upon installation. You can verify its status by running the command:

sudo systemctl status docker

Sample Output:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2025-03-14 10:00:00 UTC; 5min ago
       Docs: https://docs.docker.com
 Main PID: 1234 (dockerd)
      Tasks: 20
  Memory: 50M
   CGroup: /system.slice/docker.service
                ├─1234 /usr/bin/dockerd -H fd://
                ├─1256 containerd

4. Start and Stop Docker Service.

Stop the Docker service by running the command below:

sudo systemctl stop docker

Restart the Docker service using the following command:

sudo systemctl restart docker

5. Test the docker installation

To test this, we will create a container from the hello-world image.

docker run hello-world

Sample output:

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.
 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal.

Start a Containerized Application on Docker

Docker allows you to run applications inside containers using images from local storage or online registries like Docker Hub. Follow the steps below to run a sample Nginx container and test Docker on your server.

1. Download the latest Nginx image

Run the following command to pull the latest Nginx image from Docker Hub:

sudo docker pull nginx:latest

2. Check the available Docker images

To confirm that the Nginx image has been downloaded, list all Docker images:

sudo docker images

Output:

REPOSITORY   TAG       IMAGE ID             CREATED        SIZE
nginx                 latest    605c77e624dd   2 weeks ago    142MB

3. Run a new Docker container

Use the command below to create and start a new container:

sudo docker run --name mynginx -d -p 80:80 nginx:latest

This command does the following:

--name mynginx → Sets the container name as mynginx
-d → Runs the container in background mode
-p 80:80 → Connects server port 80 to container port 80
nginx:latest → Uses the latest Nginx image

4. Verify the running container

To check if the container is running, execute:

sudo docker ps

Output:

CONTAINER ID   IMAGE          STATUS             PORTS                       NAMES
a1b2c3d4e5f6   nginx:latest   Up 2 minutes   0.0.0.0:80->80/tcp   mynginx

5. Allow HTTP traffic through the firewall

If UFW firewall is enabled, allow port 80:

sudo ufw allow 80/tcp

6. Test the Docker container

Open your web browser and enter your server IP address:

http://SERVER-IP

Conclusion

The Docker client searched for an image called hello-world on the local system but could not find it. It then contacted Docker Hub, retrieved the image to the local system, and created a new container from that image. The container then streams this output on your terminal and exits. Docker is now installed.

Related: How to Install docker on rocky linux 9.

February 17, 2026