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
Press
Win + R, typewinver, and press Enter to check your Windows version.Open a terminal and run:
bashwslIf you see WSL-related output, it is already installed.
Otherwise, install WSL by running:
bashwsl --install
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.
Check if virtualization is enabled:
- Press
Ctrl + Shift + Escto open Task Manager. - Navigate to the CPU tab, and verify that "Virtualization" is marked as "Enabled".
- Press
Installing Docker on Windows
Now that the environment is set up, proceed to install Docker Desktop.
steps
- Go to the Docker official website.
- Download Docker Desktop for Windows.
- Open the downloaded
.exefile. Follow these steps:- Accept the terms and conditions.
- Enable the "Add shortcut to desktop" option (optional).
- Let the installer unpack and install required components.
- 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
Launch Docker Desktop.
Accept the terms of service and follow on-screen setup instructions.
Verify:
- UI shows tabs for Containers, Images, Volumes, etc.
- The Docker engine starts successfully.
Run the following test in a terminal to confirm Docker functionality:
bashdocker 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.