DEV Community

Cover image for Installing Docker on Windows: A Beginner’s Guide
Daniel Azevedo
Daniel Azevedo

Posted on

Installing Docker on Windows: A Beginner’s Guide

Hi devs,

If you're new to Docker and trying to set it up on Windows, you're in the right place! Docker is an essential tool for creating, running, and managing containers, and getting it running on Windows is easier than you might think. In this post, I'll walk you through the installation process and tackle some common problems you might run into—along with solutions to save you time and frustration!

Why Docker on Windows?

While Docker was originally designed for Linux, it’s become an essential tool for Windows developers too. Containers help streamline development by ensuring applications run the same way in all environments, be it on your machine, a colleague’s, or in production. So, let’s get Docker up and running on Windows!

System Requirements

Before you start, make sure your system meets the following requirements:

  • Windows 10 Pro, Enterprise, or Education (Build 18362 or higher)
  • Windows 11 Pro or Enterprise (any version)
  • Windows Subsystem for Linux 2 (WSL 2) enabled
  • Virtualization enabled in BIOS

If you’re using Windows Home, don’t worry! Docker Desktop now supports WSL 2, so you can still install and run Docker on Windows Home as long as you use WSL 2.


Step 1: Install Docker Desktop

  1. Download Docker Desktop:
    Go to the official Docker Desktop download page and download the Windows installer.

  2. Run the Installer:
    Double-click the installer and follow the instructions. Docker Desktop will install the necessary components, including WSL 2 if it isn’t already installed.

  3. Enable WSL 2:
    During the installation, Docker Desktop will prompt you to enable WSL 2. This is necessary to run Docker containers on Windows efficiently. You’ll need to restart your machine after enabling it.

  4. Start Docker Desktop:
    After installation, you’ll see Docker Desktop in your system tray. Click on the Docker icon and wait for it to start. Once the whale icon in the system tray stops blinking, Docker is ready to use.


Step 2: Verify Your Installation

To make sure everything is working properly, open PowerShell or Command Prompt and run:

docker --version
Enter fullscreen mode Exit fullscreen mode

This should output the version of Docker you’ve installed. Next, verify Docker can run a container:

docker run hello-world
Enter fullscreen mode Exit fullscreen mode

If this runs successfully, Docker is installed and working! 🎉


Step 3: Common Problems and How to Solve Them

1. Virtualization is Disabled

If Docker isn’t starting or you’re getting an error about virtualization, you may need to enable it in your BIOS.

Solution:

  • Restart your PC and enter the BIOS settings (usually by pressing F2, F12, or Delete during boot).
  • Look for a setting related to Virtualization Technology or Intel VT-x.
  • Enable it, save the settings, and restart your PC.

2. WSL 2 Backend Isn’t Working

Docker uses WSL 2 on Windows to run containers, and if there’s an issue with the WSL 2 backend, you might see errors like "WSL 2 installation is incomplete" or "WSL 2 kernel update required."

Solution:

  • Open PowerShell as administrator and run the following command to make sure WSL 2 is the default version:
   wsl --set-default-version 2
Enter fullscreen mode Exit fullscreen mode
  • Download the latest WSL 2 kernel update from here.
  • After installing the update, restart your system and check if Docker is working again.

3. Error: Docker Failed to Start

Sometimes Docker won’t start due to issues with its settings or configuration.

Solution:

  • Open Docker Desktop and go to Settings.
  • Under General, check if "Use the WSL 2 based engine" is enabled.
  • Also, try resetting Docker to its default settings from the Reset tab in the settings.

If this doesn’t solve the issue, try reinstalling Docker Desktop.

4. Windows Firewall or Antivirus Blocking Docker

Certain antivirus programs or firewall settings can block Docker from working properly, preventing containers from running.

Solution:

  • Temporarily disable your firewall or antivirus and try starting Docker again.
  • If Docker works, add an exception for Docker Desktop in your antivirus or firewall settings.

5. Low Resources (CPU/Memory) Allocation

Docker requires a certain amount of CPU and memory to run smoothly, and if it’s not allocated enough, you might see performance issues or Docker failing to start.

Solution:

  • Open Docker Desktop and go to Settings > Resources.
  • Increase the CPU and memory allocation to ensure Docker has enough resources.

6. Incompatible Hyper-V

If Docker refuses to run and gives errors related to Hyper-V, your system may not be set up correctly for container virtualization.

Solution:

  • Ensure that Hyper-V is enabled. Open PowerShell and run:
   dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All
Enter fullscreen mode Exit fullscreen mode
  • Restart your PC and try launching Docker again.

Final Thoughts

Docker on Windows might seem a little trickier than on Linux, but with the help of WSL 2, it’s now easier than ever. By following these steps, you’ll have Docker running on Windows, and you’ll be ready to start exploring the world of containers.

Top comments (0)