Beginner10 min readUpdated Jan 2025

How to Install Docker on Linux, macOS, and Windows


So now you know what Docker is and why it’s important. But the real fun starts when you actually install Docker on your own system and run your first container. Let’s go step by step for Linux, macOS, and Windows.


1. Install Docker on Linux

Most servers and cloud machines run on Linux, so Docker support here is first-class.

Step 1: Update your existing packages

sudo apt update
sudo apt upgrade -y

Step 2: Install required packages

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

Step 3: Add Docker’s official 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

Step 4: Add Docker repo

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 docker-ce docker-ce-cli containerd.io -y

Step 6: Verify Installation

docker --version

👉 To run Docker without sudo:

sudo usermod -aG docker $USER
newgrp docker

Now you can test with:

docker run hello-world

2. Install Docker on macOS

On macOS, Docker runs inside a lightweight VM (since macOS kernel is not Linux).

Method 1: Install with Docker Desktop (Recommended)

  1. Go to Docker Desktop for Mac.

  2. Download the .dmg file.

  3. Drag and drop Docker app to Applications.

  4. Launch Docker → you’ll see the whale icon in the top bar.

  5. Test with:

    docker run hello-world
    

Method 2: Install with Homebrew (CLI-friendly)

brew install --cask docker
open /Applications/Docker.app

3. Install Docker on Windows

On Windows, Docker also uses a VM layer, but Docker Desktop makes it simple.

Step 1: Enable WSL 2 (Windows Subsystem for Linux)

  • Open PowerShell (as Admin) and run:
wsl --install
  • Restart your system.

Step 2: Install Docker Desktop

  1. Download Docker Desktop for Windows.
  2. Run the installer and select WSL 2 backend.
  3. After installation, start Docker Desktop → check the whale icon in the taskbar.

Step 3: Verify Installation

Open PowerShell or CMD:

docker --version
docker run hello-world

Quick Comparison

Platform Installation Method Notes
Linux Package manager (apt/yum/dnf) Best performance, direct kernel access
macOS Docker Desktop or Homebrew Runs in lightweight VM
Windows Docker Desktop with WSL2 Needs virtualization enabled

Common Issues & Fixes

  • Permission Denied (Linux): Add user to docker group.
  • Docker Desktop not starting (Windows/macOS): Check virtualization is enabled in BIOS.
  • Slow performance (Windows): Allocate more CPU/RAM in Docker Desktop settings.

FAQs on Installing Docker

Q1. Can I install Docker on Windows without WSL2? Yes, but Docker Desktop officially recommends WSL2. Without it, you’ll face performance issues.

Q2. Is Docker Desktop free? For individuals, students, and small businesses—yes. Enterprises may need a subscription.

Q3. Can I install Docker on any Linux distro? Yes, Docker supports Ubuntu, Debian, CentOS, Fedora, and many others.

Q4. Do I need admin rights to install Docker? Yes, installation requires root/admin privileges. After setup, you can run as a normal user.

Q5. What’s the difference between Docker Desktop and Docker Engine?

  • Docker Engine = core runtime (Linux only).
  • Docker Desktop = GUI + runtime + integration tools (for Windows/macOS).

Mastered this concept?

Take the next step in your journey to becoming a senior developer.