Developer Guides

How to Install Docker on Windows via WSL2

Step-by-step guide to installing Docker on Windows using WSL2, meeting all prerequisites and resolving common issues.

3 min read

Step-by-step guide to installing Docker on Windows using WSL2, meeting all prerequisites and resolving common issues.

Prerequisites: Setting Up Your Environment

To ensure a smooth Docker installation process on Windows using WSL2, ensure your system meets the following requirements:

prerequisites

  • Your system must run Windows 11 or Windows 10 (64-bit home/pro, version 21H2 or higher).
  • Verify if WSL (Windows Subsystem for Linux) is installed by opening a terminal and running wsl.
  • Enable system features: WSL2 and virtualization.

Verifying Windows Version and WSL Installation

  1. Press Win + R, type winver, and press Enter to check your Windows version.

  2. Open a terminal and run:

    bash
    wsl
    • If you see WSL-related output, it is already installed.

    • Otherwise, install WSL by running:

      bash
      wsl --install
  3. Enable necessary Windows features:

    • Search for Turn Windows Features On or Off in the Start menu.
    • Enable Windows Subsystem for Linux and Virtual Machine Platform.
    • Click OK and restart when prompted.
  4. Check if virtualization is enabled:

    • Press Ctrl + Shift + Esc to open Task Manager.
    • Navigate to the CPU tab, and verify that "Virtualization" is marked as "Enabled".

Installing Docker on Windows

Now that the environment is set up, proceed to install Docker Desktop.

steps

  1. Go to the Docker official website.
  2. Download Docker Desktop for Windows.
  3. Open the downloaded .exe file. Follow these steps:
    • Accept the terms and conditions.
    • Enable the "Add shortcut to desktop" option (optional).
  4. Let the installer unpack and install required components.
  5. Restart your system once the installation is complete.

Common Installation Issues and Their Solutions


Post-Installation Verification

Once Docker Desktop is installed, verify that it is functioning as expected.

steps

  1. Launch Docker Desktop.

  2. Accept the terms of service and follow on-screen setup instructions.

  3. Verify:

    • UI shows tabs for Containers, Images, Volumes, etc.
    • The Docker engine starts successfully.
  4. Run the following test in a terminal to confirm Docker functionality:

    bash
    docker run hello-world
    • The output should indicate that Docker has successfully pulled and started a test container.

Final Steps and Docker Usage

Congratulations! Docker is now installed on your Windows system. Here’s how to start using it:


FAQ

Do I need to enable virtualization for Docker on Windows?

Yes, Docker requires virtualization to run. It can be enabled in BIOS/UEFI settings if not already active.

How do I check if WSL2 is installed correctly?

Run wsl in the terminal. If a response is returned, WSL is installed. To ensure it is WSL2, use wsl --list --verbose and look for "Version 2".

What kind of containers can I run with Docker on Windows?

Docker on Windows via WSL2 supports Linux-based containers transparently. You can pull and run most Linux containers available on Docker Hub.