Back to posts

How to Install Docker: A Beginner-Friendly Guide

Learn how to install Docker on Windows, macOS, and Linux with this step-by-step guide. Get up and running with containerization in minutes.

Fernanda
8 min read
DockerDevOpsTutorialInstallationContainers
How to Install Docker: A Beginner-Friendly Guide
Share:

What is Docker?

Docker is a platform that enables developers to package applications into containers—standardized executable components that combine application source code with all the operating system libraries and dependencies required to run that code in any environment.

Why Use Docker?

  • Consistency: Run the same environment everywhere (dev, staging, production)
  • Isolation: Keep applications and their dependencies separate
  • Portability: Move containers between different systems easily
  • Efficiency: Lightweight compared to traditional virtual machines
  • Speed: Start containers in seconds, not minutes

Prerequisites

Before installing Docker, ensure you have:

  • Administrator/sudo access to your system
  • 64-bit operating system
  • Virtualization enabled in BIOS (for Windows/Mac)
  • Minimum 4GB RAM (8GB recommended)

Installation on Windows

Step 1: Check System Requirements

Docker Desktop for Windows requires:

  • Windows 10 64-bit: Pro, Enterprise, or Education (Build 19041 or higher)
  • OR Windows 11 64-bit
  • WSL 2 feature enabled

Step 2: Download Docker Desktop

  1. Visit Docker Desktop for Windows
  2. Click "Download for Windows"
  3. Run the installer: Docker Desktop Installer.exe

Step 3: Install Docker Desktop

# The installer will:
# 1. Enable WSL 2 (if not already enabled)
# 2. Install Docker Desktop
# 3. Create desktop shortcut
  1. Double-click the installer
  2. Follow the installation wizard
  3. Check "Use WSL 2 instead of Hyper-V" (recommended)
  4. Complete the installation
  5. Restart your computer

Step 4: Verify Installation

Open PowerShell or Command Prompt:

docker --version
# Output: Docker version 24.0.0, build abc123

docker run hello-world
# Should download and run a test container

Installation on macOS

Step 1: Check System Requirements

Docker Desktop for Mac requires:

  • macOS 11 or newer
  • Apple Silicon (M1/M2) or Intel processor

Step 2: Download Docker Desktop

  1. Visit Docker Desktop for Mac
  2. Choose your chip:
    • Apple Silicon: Download for Apple Chip
    • Intel: Download for Intel Chip

Step 3: Install Docker Desktop

# Open the downloaded .dmg file
# Drag Docker icon to Applications folder
  1. Open the .dmg file
  2. Drag Docker.app to Applications folder
  3. Open Docker from Applications
  4. Grant necessary permissions when prompted
  5. Wait for Docker to start (whale icon in menu bar)

Step 4: Verify Installation

Open Terminal:

docker --version
# Output: Docker version 24.0.0, build abc123

docker run hello-world
# Should download and run a test container

Installation on Linux (Ubuntu/Debian)

Method 1: Using Repository (Recommended)

Step 1: Update Package Index

sudo apt-get update

Step 2: Install Prerequisites

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: Set Up Repository

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-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Step 6: Verify Installation

docker --version
# Output: Docker version 24.0.0, build abc123

sudo docker run hello-world
# Should download and run a test container

Method 2: Using Convenience Script

# Download and run the convenience script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

Post-Installation Steps (Linux)

Add User to Docker Group

To run Docker without sudo:

# Create docker group (if not exists)
sudo groupadd docker

# Add your user to the docker group
sudo usermod -aG docker $USER

# Activate changes
newgrp docker

# Verify (no sudo needed)
docker run hello-world

Enable Docker on Startup

sudo systemctl enable docker.service
sudo systemctl enable containerd.service

Verify Docker Installation

After installation on any platform, verify Docker is working:

Check Version

docker --version
docker compose version

Run Test Container

docker run hello-world

Expected Output:

Hello from Docker!
This message shows that your installation appears to be working correctly.

Check Docker Info

docker info

This displays detailed information about your Docker installation.


Basic Docker Commands

Now that Docker is installed, here are essential commands to get started:

Working with Images

# Pull an image from Docker Hub
docker pull nginx

# List downloaded images
docker images

# Remove an image
docker rmi nginx

Working with Containers

# Run a container
docker run -d -p 80:80 nginx

# List running containers
docker ps

# List all containers (including stopped)
docker ps -a

# Stop a container
docker stop <container_id>

# Remove a container
docker rm <container_id>

Quick Example: Run Nginx Web Server

# Run nginx on port 8080
docker run -d -p 8080:80 --name my-nginx nginx

# Visit http://localhost:8080 in your browser
# You should see "Welcome to nginx!"

# Stop and remove
docker stop my-nginx
docker rm my-nginx

Common Issues & Solutions

Issue 1: Permission Denied (Linux)

Error:

Got permission denied while trying to connect to the Docker daemon socket

Solution:

# Add user to docker group
sudo usermod -aG docker $USER
newgrp docker

Issue 2: Docker Desktop Won't Start (Windows/Mac)

Solutions:

  • Ensure virtualization is enabled in BIOS
  • Update to latest Windows/macOS version
  • Restart Docker Desktop
  • Check Docker Desktop logs: Settings → Troubleshoot

Issue 3: WSL 2 Installation Incomplete (Windows)

Solution:

# Install WSL 2 manually
wsl --install
wsl --set-default-version 2

Next Steps

Now that Docker is installed, you can:

  1. Learn Docker Basics: Practice with simple containers
  2. Create Dockerfiles: Build your own images
  3. Use Docker Compose: Manage multi-container applications
  4. Explore Docker Hub: Find pre-built images
  5. Read Documentation: Visit docs.docker.com

Useful Resources


Conclusion

You've successfully installed Docker! Whether you're on Windows, macOS, or Linux, you now have a powerful containerization platform at your fingertips. Start experimenting with containers and discover how Docker can streamline your development workflow.

Happy containerizing! 🐳


Questions about Docker installation? Drop a comment below!