What is Docker?
Docker is an open-source platform that helps you build, ship, and run applications inside containers. Containers are lightweight, portable units that package code, dependencies, and system tools needed to run an application—ensuring consistency across environments.

Why Use Docker?
🧱 Simplifies deployment

💻 Makes applications portable

⚙️ Runs the same on all systems

📦 Saves system resources with containerized apps

Prerequisites

  • You need a 64-bit Ubuntu system (20.04 or later recommended).
  • You should have sudo/root access.
  • Internet connection 😄

Step-by-Step Installation
1️⃣ Update Your System

sudo apt update
sudo apt upgrade -y

2️⃣ Install Required Packages

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

3️⃣ Add Docker’s GPG Key

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

4️⃣ Add Docker Repo to APT Sources

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

5️⃣ Update Package List & Install Docker

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

6️⃣ Verify Installation

docker --version

7️⃣ Run a Test Container

docker run hello-world

You should see a success message from the Docker daemon 🎉

Common Errors & Fixes

  • Permission denied: Run with sudo or add user to Docker group.
  • GPG key issues: Ensure your key file path is correct.
  • Old version?: Uninstall with sudo apt remove docker docker-engine and repeat steps.

Summary

sudo apt update && sudo apt upgrade -y
sudo apt install ca-certificates curl gnupg lsb-release -y
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
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
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
docker --version
docker run hello-world

Conclusion
That’s it! You’ve successfully installed Docker on your Ubuntu system. You’re now ready to build, run, and manage containers like a pro 💪