Installing Docker on Ubuntu

This guide walks you through the process of installing Docker on Ubuntu 24.04. Whether you’re a developer, system administrator, or hobbyist, Docker allows you to containerize applications and run them efficiently across different environments. Follow these steps to get Docker up and running on your system in minutes.

Prerequisites

  • A system running Ubuntu 24.04.
  • A user account with sudo privileges.
  • Internet connection.

Step 1: Update the System

Before installing Docker, update the existing list of packages:

sudo apt update
sudo apt upgrade -y
Bash

Step 2: Install Required Dependencies

Install packages that allow apt to use repositories:

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

Step 3: Add Docker’s Official GPG Key

Grab the Keyring:

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

Add the Docker repository to APT:

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
Bash

Step 4: Install Docker

Update the APT package index:

sudo apt update
Bash

Install Docker and its components:

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

Step 5: Verify Installation

Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:

sudo systemctl status docker
Bash

Optional: Run Docker as a Non-Root User

To avoid using sudo with Docker commands:

  • Add your user to the docker group:  
sudo usermod -aG docker $USER
Bash

Make sure you replace $USER with your username

  • Log out and log back in.
  • Test again.
docker run hello-world
Bash

Conclusion

Docker should now be installed and running on your Ubuntu 24.04 system. You’re ready to start building and running containers!