Install Docker on Windows

Installing Docker on Windows requires enabling virtualization and choosing between Docker Desktop or WSL2 integration. This guide covers all installation methods.

System Requirements

  • Windows 10 version 2004+ (Build 19041+)
  • At least 4GB RAM
  • Virtualization enabled in BIOS
  • Hyper-V and Containers Windows features enabled

Prerequisites Setup

Enable Virtualization

  1. Restart your computer
  2. Enter BIOS/UEFI settings (usually F2, F12, or Delete)
  3. Enable Intel VT-x or AMD-V
  4. Save and exit

Enable Windows Features

  1. Open Turn Windows features on or off
  2. Enable:
    • Hyper-V
    • Windows Subsystem for Linux
    • Virtual Machine Platform
  3. Restart your computer

Install WSL2 (Recommended)

Open PowerShell as Administrator:

wsl --install

This installs Ubuntu and WSL2. Restart after installation.

Method 1: Docker Desktop (Recommended)

Download Docker Desktop

  1. Visit Docker Desktop for Windows
  2. Download the installer
  3. Run the installer with administrator privileges

Installation Steps

  1. Check “Use WSL 2 instead of Hyper-V” (recommended)
  2. Complete the installation
  3. Restart your computer when prompted
  4. Launch Docker Desktop from Start Menu

Initial Configuration

  1. Accept Docker Desktop Service Terms
  2. Docker will start automatically
  3. Look for the whale icon in your system tray

Verify Installation

Open Command Prompt or PowerShell:

docker --version
docker compose version
docker run hello-world

Method 2: Windows Package Manager (Winget)

winget install Docker.DockerDesktop

Method 3: Chocolatey

choco install docker-desktop

Docker Desktop Configuration

WSL2 Backend (Recommended)

  1. Right-click Docker Desktop icon > Settings
  2. Go to General
  3. Check “Use the WSL 2 based engine”
  4. Click “Apply & Restart”

Resource Allocation

  1. Go to Settings > Resources
  2. Adjust as needed:
    • Memory: 4GB+ (recommended 8GB)
    • CPU: 2+ cores
    • Disk: 64GB+

File Sharing

  1. Go to Settings > Resources > File Sharing
  2. Add your project directories
  3. Apply changes

Kubernetes (Optional)

  1. Go to Settings > Kubernetes
  2. Enable Kubernetes
  3. Wait for installation

WSL2 Integration

Check WSL2 Status

wsl -l -v

Set WSL2 as Default

wsl --set-default-version 2

Docker Integration with WSL2

Docker Desktop automatically integrates with WSL2. You can run Docker commands from both Windows and WSL2 terminals.

Command Line Setup

Windows Terminal (Recommended)

Install from Microsoft Store for better terminal experience with tabs and PowerShell/WSL2 integration.

PowerShell Profile Setup

# Open PowerShell profile
notepad $PROFILE

# Add Docker aliases
Set-Alias -Name d -Value "docker"
Set-Alias -Name dc -Value "docker compose"
Set-Alias -Name dps -Value "docker ps"
Set-Alias -Name di -Value "docker images"

Development Environment

VS Code Integration

  1. Install VS Code from code.visualstudio.com
  2. Install Docker extension by Microsoft
  3. Install WSL extension for remote development

Git Integration

Install Git for Windows from git-scm.com

Common Issues and Solutions

Virtualization Not Enabled

# Check virtualization status
systeminfo | findstr "Virtualization"

# If disabled, enable in BIOS

WSL2 Installation Issues

# Reset WSL
wsl --shutdown
wsl --unregister Ubuntu
wsl --install

Docker Desktop Won’t Start

  1. Restart Docker Desktop
  2. Restart WSL: wsl --shutdown
  3. Check Windows Features are enabled
  4. Update Windows to latest version

Port Conflicts

# Find process using port
netstat -ano | findstr :8080

# Kill process
taskkill /PID <PID_NUMBER> /F

Out of Disk Space

# Clean Docker system
docker system prune -a

# Increase disk allocation in Docker Desktop Settings

Performance Issues

  1. Enable WSL2 backend in Docker Desktop
  2. Increase memory allocation
  3. Use .dockerignore files
  4. Optimize Dockerfile layers

Docker Compose Usage

docker-compose.yml Example

version: '3.8'
services:
  web:
    build: .
    ports:
      - "3000:3000"
    volumes:
      - .:/app
    environment:
      - NODE_ENV=development
  
  database:
    image: postgres:13
    environment:
      - POSTGRES_DB=myapp
      - POSTGRES_USER=user
      - POSTGRES_PASSWORD=password
    ports:
      - "5432:5432"

Common Docker Compose Commands

# Start services
docker compose up -d

# View logs
docker compose logs -f

# Stop services
docker compose down

# Rebuild services
docker compose up --build

Production Deployment

Build and Export Image

docker build -t myapp:v1.0 .
docker save -o myapp.tar myapp:v1.0

Push to Registry

docker tag myapp:v1.0 username/myapp:v1.0
docker push username/myapp:v1.0

Security Best Practices

Regular Updates

# Check for updates in Docker Desktop
# Settings > General > Check for updates automatically

Container Security

# Run containers as non-root
USER node

# Use multi-stage builds
FROM node:16-alpine as builder
# build steps
FROM node:16-alpine
COPY --from=builder /app/dist ./app

Sources

For other platforms, check our Docker Linux installation or macOS Docker setup.