A Step-by-Step Guide to Installing Docker Desktop on Windows 11 using WSL 2

Learn to install Docker Desktop on Windows 11 using WSL 2. Docker packages apps into containers; WSL 2 runs Linux directly on Windows for better Docker performance.

A Step-by-Step Guide to Installing Docker Desktop on Windows 11 using WSL 2

Docker is a tool that helps software developers package applications and their necessary components together. Think of it like putting an application and everything it needs to run into a standardized box called a "container." This makes it easier to build, share, and run software consistently on different computers.

On Windows 11, Docker Desktop works very effectively, especially when used with a Windows feature called the Windows Subsystem for Linux 2 (WSL 2). WSL 2 allows Windows to run a genuine Linux environment directly, which helps Docker run applications faster and more efficiently compared to older methods.

This guide provides detailed steps to install Docker Desktop on your Windows 11 computer and configure it to work with WSL 2.

System Requirements (Prerequisites)

Before starting the installation, please verify that your computer meets these requirements:

  1. Windows 11 Operating System: A 64-bit version of Windows 11 Pro, Enterprise, or Education is recommended (specifically, Build 19044 or a more recent version). Docker Desktop can also be installed on Windows 11 Home, but it strictly requires WSL 2, which this guide covers.
  2. WSL 2 Enabled: The Windows Subsystem for Linux feature must be installed on your system and configured to use version 2.
  3. Installed Linux Distribution: You need at least one Linux operating system (like Ubuntu) installed through the Microsoft Store for WSL. Ubuntu is a common and reliable choice.
  4. Hardware Virtualization Enabled: Your computer's processor must support virtualization, and this feature needs to be enabled in the system's BIOS or UEFI settings. Most modern computers have this turned on by default. If you encounter problems later, you may need to restart your computer and access the BIOS/UEFI settings (often by pressing keys like F2, F10, or Del during startup) to find and enable options such as "Intel VT-x," "AMD-V," or "SVM Mode."

Step 1: Enable Required Windows Features (WSL and Virtualization)

If you haven't already enabled the necessary Windows features, you can do so using the Windows PowerShell application.

  1. Open PowerShell with Administrator Privileges: Click the Start button, type "PowerShell," right-click on the "Windows PowerShell" result, and select "Run as administrator." Confirm any prompts asking for permission.
  2. Restart Your Computer: A system restart is necessary for these changes to be applied correctly. Please restart your computer now.

Enable the Virtual Machine Platform: Copy and paste this next command into PowerShell and press Enter:

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Enable the Windows Subsystem for Linux: Copy and paste the following command into the PowerShell window, then press Enter:

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 2: Install a Linux Operating System via Microsoft Store (If Needed)

If you do not already have a Linux system installed for WSL, you can easily obtain one from the Microsoft Store.

  1. Open the Microsoft Store application (you can find it in the Start menu).
  2. In the search bar, type "Ubuntu" (or another distribution like "Debian" if you prefer). The standard Ubuntu release (often marked LTS for Long-Term Support) is recommended for general use.
  3. Click the "Install" or "Get" button for the distribution you chose.
  4. After the download and installation are complete, find the Linux distribution (e.g., Ubuntu) in your Start menu and launch it. The first time it runs, it will perform some initial setup, which may take a few minutes. You will be asked to create a username and password for use within this Linux environment. Please choose these carefully and remember them.

Step 3: Configure WSL to Use Version 2 by Default

It's important to ensure that WSL uses version 2 for optimal performance with Docker.

  1. Open PowerShell with Administrator Privileges (if you closed the previous window).

(Optional) Check the WSL Version of Existing Installations: If you previously installed Linux distributions, you can check which WSL version they are using. Run this command in PowerShell:

wsl --list --verbose

This command displays a list of your installed Linux systems and the WSL version (1 or 2) assigned to each. If you have an installation using version 1 that you wish to update, use the following command, replacing <DistroName> with the actual name shown in the list (e.g., "Ubuntu"):

wsl --set-version <DistroName> 2

The conversion process might take several minutes.

Set WSL 2 as the default version: Copy and paste this command into PowerShell and press Enter:

wsl --set-default-version 2

Note: If you receive a message about updating the WSL kernel, run the command wsl --update in the administrator PowerShell window, wait for it to complete, and then run the wsl --set-default-version 2 command again.

Step 4: Download and Install Docker Desktop

Now, you can proceed with installing the Docker Desktop application.

  1. Open your web browser and navigate to the official Docker website: https://www.docker.com/products/docker-desktop/
  2. Click the button to download the Docker Desktop for Windows installer file.
  3. Locate the downloaded installer file (usually named Docker Desktop Installer.exe) in your Downloads folder and double-click it to run.
  4. Follow the steps presented by the installation wizard. During the process, ensure that the configuration option "Use WSL 2 instead of Hyper-V" is selected (checked). This option is typically enabled automatically if the installer detects a working WSL 2 setup, but it's good practice to verify.
  5. After the installation completes, Docker Desktop may prompt you to log out of Windows and log back in, or to restart your computer. Please follow the instructions provided.

Step 5: Configure Docker Desktop Settings for WSL 2

After Docker Desktop is installed (and you have restarted or logged back in if required), it should start automatically. You can confirm its settings as follows:

  1. Locate the Docker icon (a whale symbol) in the Windows system tray, typically found near the clock in the bottom-right corner of the screen. If the icon is not visible, open Docker Desktop from the Start menu.
  2. Right-click on the Docker system tray icon and select Settings.
  3. In the Settings window, select the General tab from the left-hand menu.
  4. Verify that the checkbox labeled "Use the WSL 2 based engine" is selected. If it is not, click the checkbox to enable it, and then click the "Apply & Restart" button.
  5. Next, select the Resources tab, and then click on WSL Integration.
  6. Ensure the main toggle switch labeled "Enable integration with my default WSL distro" is turned on.
  7. Below this, you will see a list of the Linux distributions you have installed via WSL (e.g., Ubuntu). To allow Docker commands to be run from within a specific Linux environment, turn the toggle switch on for that distribution. Enable it for the distributions you intend to use with Docker.
  8. Click the "Apply & Restart" button to save these settings.

Step 6: Verify the Docker Installation

Finally, let's perform a quick check to ensure Docker is installed and running correctly.

  1. Open Windows PowerShell or Windows Terminal.

(Optional) Verify Integration from within WSL: You can also test Docker from inside your Linux environment. Launch your installed Linux distribution (e.g., Ubuntu) from the Start menu. In the Linux terminal window that appears, type the following commands, pressing Enter after each:

# These commands are run inside the Linux terminal
docker --version
docker run hello-world

If these commands also execute successfully and show the version or the "Hello from Docker!" message, the integration with WSL 2 is working correctly.

Run a standard test container by typing this command and pressing Enter:

docker run hello-world

Docker will download a small test image and run it. If the installation is successful, you will see a message on your screen that begins with "Hello from Docker!".

Type the following command and press Enter to check the installed Docker version:

docker --version

The command should output the version numbers for the Docker client and engine.

Installation Complete

You have now successfully installed Docker Desktop on your Windows 11 computer and configured it to use the WSL 2 backend for improved performance. This setup provides a reliable environment for working with Docker containers directly on Windows. You are now ready to begin using Docker for your software projects.

Further Reading & References

For more detailed information, you may find these official resources helpful: