How to Install Docker on Windows: Step-by-Step Guide
To install
Docker on Windows, download and install Docker Desktop for Windows from the official Docker website. After installation, start Docker Desktop and follow the setup prompts to enable WSL 2 or Hyper-V, then verify installation by running docker --version in PowerShell or Command Prompt.Syntax
Installing Docker on Windows mainly involves downloading the installer and running it. The key commands to verify installation are:
docker --version: Checks Docker version installed.wsl --list --verbose: Lists WSL 2 distributions if using WSL backend.
Docker Desktop uses either WSL 2 or Hyper-V as its backend on Windows.
bash
docker --version wsl --list --verbose
Output
Docker version 24.0.5, build abcdefg
NAME STATE VERSION
* Ubuntu Running 2
Example
This example shows how to install Docker Desktop on Windows and verify it works by running a test container.
docker
1. Download Docker Desktop installer from https://www.docker.com/products/docker-desktop 2. Run the installer and follow prompts to enable WSL 2 or Hyper-V 3. Restart your computer if prompted 4. Open PowerShell or Command Prompt 5. Run: docker --version 6. Run a test container: docker run hello-world
Output
Docker version 24.0.5, build abcdefg
Hello from Docker!
This message shows that your installation appears to be working correctly.
Common Pitfalls
Common issues when installing Docker on Windows include:
- Not enabling WSL 2 or Hyper-V features before installation.
- Running Docker Desktop on unsupported Windows editions (needs Windows 10 Pro, Enterprise, or Windows 11).
- Not restarting the computer after installation or enabling features.
- Conflicts with other virtualization software like VirtualBox.
Make sure your Windows version supports Docker Desktop and that virtualization is enabled in BIOS.
powershell
REM Wrong: Trying to run Docker without enabling WSL 2 or Hyper-V > docker run hello-world Error: Docker daemon not running REM Right: Enable WSL 2 feature before installing Docker > dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart > dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Quick Reference
Summary tips for installing Docker on Windows:
- Use Windows 10 Pro/Enterprise or Windows 11 for best support.
- Enable WSL 2 and Virtual Machine Platform features before installing.
- Download Docker Desktop from the official site only.
- Restart your PC after installation and feature enablement.
- Verify installation with
docker --versionanddocker run hello-world.
Key Takeaways
Download and install Docker Desktop from the official Docker website.
Enable WSL 2 or Hyper-V features on Windows before installing Docker.
Restart your computer after installation to apply changes.
Verify installation by running 'docker --version' and 'docker run hello-world'.
Use Windows 10 Pro/Enterprise or Windows 11 for full Docker Desktop support.