How to Install Docker on Ubuntu 24.04

Grigor Khachatryan
2 min readOct 6, 2024

--

Introduction

Docker has revolutionized the way we develop and deploy applications by providing a simple way to package and run applications in isolated environments called containers. These containers are lightweight, portable, and ensure consistency across different development and production environments.

In this tutorial, you’ll learn how to install Docker on an existing installation of Ubuntu 24.04 LTS using multiple methods, so you can choose the one that best fits your needs.

Note: Docker requires a 64-bit version of Ubuntu and a kernel version of at least 3.10. Ubuntu 24.04 meets these requirements.

Prerequisites

  1. A non-root user with `sudo` privileges.
  2. An updated system:
sudo apt update && sudo apt upgrade -y

Method 1: Install from Ubuntu’s Default Repositories

This is the quickest method but may not install the latest Docker version.

Install Docker:

sudo apt install -y docker.io

Start and Enable Docker:

sudo systemctl start docker
sudo systemctl enable docker

Verify Installation:

sudo docker run hello-world

You should see a message saying “Hello from Docker!”

Method 2: Install Using the Official Docker Repository (Recommended)

This method ensures you get the latest version of Docker.

Uninstall Old Versions (if any):

sudo apt remove -y docker docker-engine docker.io containerd runc

Install Dependencies:

sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release

Add Docker’s Official GPG Key:

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

Add the Docker Repository:

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 Package Database:

sudo apt update

Install Docker Engine:

sudo apt install -y docker-ce docker-ce-cli containerd.io

Verify Installation:

sudo docker run hello-world

Method 3: Install Using Snap Packages

Snaps are containerized software packages that are simple to create and install.

Install Docker Snap Package:

sudo snap install docker

Verify Installation:

sudo docker run hello-world

Running Docker Commands Without Sudo (Optional)

By default, you need to use sudo to run Docker commands. To avoid this:

Create Docker Group:

sudo groupadd docker

(If the group already exists, you’ll get a message saying so.)

Add Your User to the Docker Group:

sudo usermod -aG docker $USER

Apply the New Group Membership:

Log out and log back in, or type:

newgrp docker

Verify You Can Run Docker Commands Without Sudo:

docker run hello-world

Conclusion

Congratulations! You’ve successfully installed Docker on Ubuntu 24.04 using the method of your choice. You can now start leveraging Docker to containerize your applications, ensuring consistency across development and production environments.

Like to learn more?

Find more in-depth guides on my website.
Follow me on Twitter for updates in AI, DevOps, and tech.
Connect on LinkedIn to chat or collaborate!

--

--