Keyboard Shortcuts N Next post
P Previous post
S Save / unsave
R Read aloud
T Toggle theme
/ Focus search
Esc Close panels
🔥
Ready to read...
Docker Docker & Containers: From Zero to Production Docker Basics Module 1 — Container Fundamentals setup

Installing Docker on macOS, Windows, and Linux

Reviewed & accurate
AI Summary

What You'll Learn

Beginner

  • How to install Docker on macOS, Windows, and Linux
  • The difference between Docker Desktop and Docker Engine
  • How to verify your installation works
  • Common installation issues and their fixes

Docker Desktop vs Docker Engine

AspectDocker DesktopDocker Engine
PlatformmacOS, WindowsLinux
IncludesEngine + GUI + Compose + BuildKitJust the engine (CLI + daemon)
LicenseFree for personal/small orgs; paid for largeFree and open source
ArchitectureRuns Linux containers in a VMRuns containers natively
Resource usageHigher (VM overhead)Lower (native)
Which should I use?
On macOS or Windows: Docker Desktop (it's the only option). On Linux: Docker Engine (native, lighter, free for all uses).

Install on macOS

Download the correct version: Apple Silicon (M1/M2/M3) or Intel (older Macs)
Double-click the downloaded .dmg file
Drag the Docker icon to your Applications folder
Open Docker from Applications (it will ask for your password to install components)
Wait for the Docker whale icon in your menu bar to stop animating
Open Terminal and run docker --version to verify

Install on Windows

Requirements
Windows 10/11 64-bit with WSL 2 (Windows Subsystem for Linux) enabled. Most modern Windows installations support this.
Download Docker Desktop Installer.exe
Run the installer (accept defaults, ensure "Use WSL 2 instead of Hyper-V" is checked)
Restart your computer if prompted
Open Docker Desktop from the Start menu
Complete the tutorial (optional) or skip
Open PowerShell or Command Prompt and run docker --version

Install on Linux (Ubuntu/Debian)

Official method
Docker's official repository has the latest version. Distribution packages (e.g., apt install docker.io) are often outdated.
Terminal — Ubuntu/Debianbash
# Update apt and install prerequisites
sudo apt-get update
sudo apt-get install 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 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 Docker Engine
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Post-installation step (Linux only)

By default, only root can run Docker commands. Add your user to the docker group to run without sudo:

Terminalbash
sudo usermod -aG docker $USER
# Log out and log back in for changes to take effect
# Or run: newgrp docker
Security note
Adding your user to the docker group grants root-equivalent privileges. Only do this on a development machine, not on a shared production server.

Verify Your Installation

Run these commands to confirm Docker is working:

Terminalbash
# 1. Check Docker version
docker --version
# Docker version 24.0.7, build afdd53b

# 2. Check detailed info (client + daemon)
docker version

# 3. Check daemon is running and see system info
docker info

# 4. Run the hello-world container
docker run hello-world

# 5. Check Docker Compose is installed
docker compose version

If docker run hello-world prints a welcome message, your installation is working correctly.

Common Installation Issues

Issue 1: "Cannot connect to the Docker daemon"

Cause & Fix
Cause: The Docker daemon is not running.
Fix (Linux): sudo systemctl start docker and sudo systemctl enable docker
Fix (macOS/Windows): Start Docker Desktop from Applications

Issue 2: "Permission denied" on Linux

Cause & Fix
Cause: Your user is not in the docker group.
Fix: sudo usermod -aG docker $USER, then log out and back in.
Quick test: sudo docker run hello-world — if this works, it's a permission issue.

Issue 3: Docker Desktop won't start on Windows

Cause & Fix
Cause: WSL 2 not installed or not set as default.
Fix: Run wsl --install in PowerShell as admin, restart, then wsl --set-default-version 2

Issue 4: Slow on macOS/Windows

Performance tip
Docker Desktop on macOS/Windows runs containers in a Linux VM. File system operations across the host-container boundary are slow. Use named volumes (not bind mounts) for databases and use caching in Docker Desktop settings: Settings → Resources → File sharing.

Configuration Recommendations

After installing, adjust these Docker Desktop settings (macOS/Windows):

SettingRecommendedWhy
Memory4-8 GBDefault 2 GB is too low for most apps
CPU4 coresMore cores = faster builds
Swap1 GBFor memory-heavy builds
Disk image size64+ GBImages accumulate; running out of space breaks Docker

Common Mistakes

Avoid these
  • Using distribution packages on Linux. apt install docker.io installs an older version. Use Docker's official repository.
  • Not adding user to docker group on Linux. You'll need sudo for every command, which is annoying and dangerous for scripts.
  • Ignoring Docker Desktop resource limits. Default 2 GB RAM is too low for multi-container apps. Increase it.
  • Not updating Docker. Old versions have bugs and security issues. Update regularly: sudo apt upgrade docker-ce (Linux) or auto-update in Desktop settings.

Practical Exercise (10 minutes)

Install Docker on your OS using the steps above
Run docker --version — confirm it prints a version
Run docker run hello-world — confirm you see the welcome message
Run docker run -it ubuntu bash — get an interactive shell in Ubuntu
Inside the container, run apt-get update && apt-get install -y curl
Run curl https://example.com — you have network access from inside the container
Type exit to leave

Mini Challenge

Run docker info and identify: (1) your Docker version, (2) the storage driver, (3) how many images you have locally, (4) how much disk space Docker is using. Understanding docker info is essential for troubleshooting.

Key Takeaways

  • Docker Desktop for macOS/Windows (includes GUI, runs Linux containers in a VM).
  • Docker Engine for Linux (native, lighter, free for all uses).
  • Always use Docker's official repository on Linux — distribution packages are outdated.
  • Add your user to the docker group on Linux to avoid sudo.
  • Verify with docker run hello-world — if it prints a welcome message, Docker works.
Previously: Lesson 04 covered the Docker architecture.
Today: You installed Docker on your OS and verified it works.
Next: Lesson 06 runs your first real container and explains what happens.

FAQ

Do I need to uninstall old Docker versions first?

On Linux, yes — old versions used different package names (docker, docker-engine). Run sudo apt remove docker docker-engine docker.io containerd runc before installing the new version. On macOS/Windows, Docker Desktop auto-updates.

Can I run Docker without Docker Desktop on macOS?

Technically yes, using colima or podman, but Docker Desktop is the recommended path for most users. Colima is lighter but lacks the GUI and some features.

Test Your Knowledge
How did you find this?

Comments

Join the discussion! Sign in with your Google or Blogger account, or comment as Anonymous - no account needed. For quick questions, also reach me on Telegram @cytestch.

Comments