Server Gigabit Guide

Install Docker on Ubuntu

You are here:
Estimated reading time: 1 min

Here’s a step-by-step guide to install Docker on Ubuntu (20.04, 22.04, or later) — clean, safe, and following Docker’s official documentation.

Step 1: Uninstall Old Versions (if any)

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

Step 2: Update Packages and Install Dependencies

sudo apt update
sudo apt install -y ca-certificates curl gnupg lsb-release

Step 3: Add Docker’s Official GPG Key

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Step 4: Add the Docker Repository

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

Step 5: Install Docker Engine

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

Step 6: Verify Docker Installation

Check the version:

docker --version

Run the test image:

sudo docker run hello-world

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

(Optional) Step 7: Run Docker Without sudo

To avoid typing sudo for every command:

sudo usermod -aG docker $USER
newgrp docker

Then test:

docker ps

Done! You now have Docker Engine, Docker Compose, and Buildx installed and ready to use on Ubuntu.

 

Was this article helpful?
Dislike 0
Views: 2