Docker Tutorial — Install Docker on Linux
Installing Docker on Linux means installing Docker Engine directly — no VM, no desktop app. Your containers run natively on the Linux kernel.
Install on Ubuntu / Debian
These steps work for Ubuntu 22.04, 24.04, and Debian 12+.
Step 1 — Remove Old Versions
$ sudo apt-get remove docker docker-engine docker.io containerd runc
Step 2 — Set Up the Docker Repository
# Install prerequisites
$ sudo apt-get update
$ sudo apt-get install -y ca-certificates curl gnupg
# 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
# Add the Docker repository
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Step 3 — Install Docker Engine
$ sudo apt-get update
$ sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 4 — Verify
$ sudo docker run hello-world
# Expected output:
# Hello from Docker!
# This message shows that your installation appears to be working correctly.
Install on CentOS / RHEL / Amazon Linux
# Install prerequisites
$ sudo yum install -y yum-utils
# Add Docker repo
$ sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
$ sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
# Start Docker
$ sudo systemctl start docker
$ sudo systemctl enable docker
Docker Engine vs Docker Desktop for Linux
| Feature | Docker Engine | Docker Desktop |
|---|---|---|
| Runtime | Native Linux | Linux VM on Linux |
| GUI | No | Yes |
| Compose | Plugin | Built-in |
| Kubernetes | No | Optional single-node |
| License | Free (Apache 2.0) | Free for personal/small biz |
For servers: use Docker Engine. For development workstations: either works.
Quick Reference
Ubuntu/Debian:
sudo apt-get install docker-ce docker-ce-cli containerd.io
CentOS/RHEL:
sudo yum install docker-ce docker-ce-cli containerd.io
Verify:
sudo docker run hello-world