Docker Installation
Docker runs on Linux natively and on macOS/Windows via a lightweight Linux VM (Docker Desktop). This guide covers installation and verification on all three platforms.
System Requirements
| Platform | Requirements |
|---|---|
| Linux | 64-bit, kernel 3.10+ (3.10 for basic, 4.0+ recommended) |
| macOS | macOS 12+ (Apple Silicon or Intel) |
| Windows | Windows 10/11 64-bit, WSL 2 enabled |
Linux — Ubuntu/Debian
Official Docker repository (recommended over apt install docker.io):
# Remove old versions
sudo apt remove docker docker-engine docker.io containerd runc 2>/dev/null
# Install prerequisites
sudo apt update
sudo apt install -y ca-certificates curl gnupg
# Add Docker 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 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
# Install
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Post-Install — Run Without sudo
sudo groupadd docker 2>/dev/null
sudo usermod -aG docker $USER
newgrp docker
# Verify
docker run hello-world
Log out and back in if newgrp doesn’t apply immediately.
Enable Docker on Boot
sudo systemctl enable docker
sudo systemctl start docker
sudo systemctl status docker
macOS — Docker Desktop
- Download from docker.com/products/docker-desktop
- Open the
.dmgand drag Docker to Applications - Launch Docker Desktop — wait for the whale icon to stop animating
- Verify in Terminal:
docker --version
docker compose version
docker run hello-world
Apple Silicon Notes
Docker Desktop runs ARM containers natively. For x86 images:
docker run --platform linux/amd64 hello-world
Most official images publish multi-arch manifests — Docker selects the correct architecture automatically.
Resource Settings
Docker Desktop → Settings → Resources:
- CPUs: 2–4 for development
- Memory: 4–8 GB depending on workloads
- Disk: monitor usage; prune regularly
Windows — Docker Desktop with WSL 2
- Enable WSL 2:
wsl --install
# Restart if prompted
- Download Docker Desktop from docker.com
- Install with “Use WSL 2 instead of Hyper-V” checked
- Verify in PowerShell or WSL terminal:
docker run hello-world
Store project files in the WSL filesystem (\\wsl$\Ubuntu\home\you\project) for best performance — not C:\ mounted paths.
Verify Installation
Run this checklist:
docker --version # Docker version 24.x or 25.x
docker compose version # Docker Compose version v2.x
docker info # System info, no errors
docker run hello-world # Pulls and runs test container
Expected hello-world output ends with:
Hello from Docker!
This message shows that your installation appears to be working correctly.
Essential Post-Install Commands
# System-wide info
docker info
# Disk usage
docker system df
# Clean up unused resources
docker system prune -a # removes stopped containers, unused networks, dangling images
# Configure registry mirrors (if needed in restricted networks)
# Edit /etc/docker/daemon.json on Linux
Linux registry mirror example:
{
"registry-mirrors": ["https://mirror.example.com"]
}
sudo systemctl restart docker
Docker Compose Plugin
Modern Docker includes Compose as a plugin (not separate docker-compose binary):
docker compose up # v2 syntax (preferred)
docker-compose up # v1 standalone (legacy)
Install is included with Docker Desktop and Linux package above.
Troubleshooting
| Issue | Fix |
|---|---|
permission denied on Linux |
Add user to docker group |
| Docker Desktop won’t start (Mac) | Reset to factory defaults in Settings |
| WSL integration not working | Settings → Resources → WSL Integration → enable distro |
Cannot connect to Docker daemon |
Start Docker Desktop or sudo systemctl start docker |
| Out of disk space | docker system prune -a --volumes |
Alternative: Colima (macOS/Linux)
Lightweight Docker runtime without Docker Desktop:
brew install colima docker
colima start
docker run hello-world
Popular among developers who prefer open-source tooling.
What Comes Next
With Docker installed, write your first Dockerfile to containerize an application, then orchestrate multi-container setups with Docker Compose.