If you want to run Docker on Windows efficiently, setting up WSL2 (Windows Subsystem for Linux) is essential. This guide walks you through installing Docker, enabling virtualization, setting up WSL2, and confirming that Docker runs successfully.
Step 1: Install Docker for Windows
First, download and install Docker Desktop for Windows from the official Docker website:
- Download the Docker Desktop installer.
- Run the installer and follow the on-screen instructions.
- Ensure "WSL2 Integration" is enabled during the installation process.
- Restart your computer if prompted.
Step 2: Enable Virtualization
Before using Docker, ensure that virtualization is enabled on your system.
- Press
Ctrl + Shift + Esc
to open Task Manager. - Navigate to the Performance tab.
- Check if Virtualization is enabled.
- If it's disabled, enable it from your system's BIOS settings.
Step 3: Install WSL2
Docker relies on WSL2 for better performance and compatibility. Follow these steps to set it up:
- Download the WSL2 Linux kernel update package from the Microsoft website: ๐ WSL2 Kernel Update
- Install the package by following the prompts.
- Open Command Prompt as Administrator and run:
wsl --set-default-version 2
Step 4: Install Ubuntu for WSL2
After enabling WSL2, install a Linux distribution such as Ubuntu.
- Open Microsoft Store.
- Search for Ubuntu.
- Click Get to download and install it.
- Launch Ubuntu and complete the initial setup (username & password).
Step 5: Update WSL
To ensure WSL is up to date, run:
wsl --update
This keeps your WSL2 environment optimized for Docker.
Step 6: Run Docker to Confirm It's Working
- Open Docker Desktop.
- Wait for it to start and ensure there are no errors.
- Open Command Prompt or PowerShell, then run:
docker --version
This should display the installed Docker version.
- Test Docker with a simple container:
docker run hello-world
If everything is set up correctly, Docker will pull and run the test container successfully.
Conclusion
With these steps, you have successfully installed Docker on Windows with WSL2. Now, you can run Linux-based containers seamlessly on your system. ๐
Top comments (0)