Thursday, 3 July 2025

How to Install Docker on Ubuntu – Step-by-Step Guide

 

Step 1 — Installing Docker

The Docker installation package available in the official Ubuntu repository may not be the latest version. To ensure we get the latest version, we’ll install Docker from the official Docker repository.


The command sudo apt install apt-transport-https ca-certificates curl software-properties-common is used on Debian-based Linux distributions (like Ubuntu) to install several essential packages

  • Add a new software repository that uses HTTPS: This command ensures apt can securely communicate with that repository and verify its identity.

  • Install software from a source that requires curl for setup: Many third-party instructions rely on curl for initial downloads.

  • goog_1410673038

    Easily manage new APT repositories: software-properties-common provides the tools to streamline the addition of external software sources.



The Purpose of GPG Keys in APT Repositories

When you install software on a Debian-based system (like Ubuntu) using apt, the package manager relies on a system of trust to ensure that the packages you download are legitimate and haven't been tampered with. This trust is established through GPG (GNU Privacy Guard) keys

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


Add the Docker repository to APT sources:

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 your existing list of packages again for the addition to be recognized:

Sudo apt Update


Make sure you are about to install from the Docker repo instead of the default Ubuntu repo


Finally install Docker

sudo apt install docker-ce


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


Check docker version

docker -v



Docker command s list