Simple guide to using Docker on Windows 10 and access from WSL 2
Introduction¶
For a heavy linux user like me, using windows also mean find a door to work with a linux distro. There are several options to gauge from the situation. I usually need both docker and wsl2 on the computer. And i've installed this many times.
So, this is a very straight forward tutorial on docker and wsl2 installation and configuration on windows10 or 11.
Prerequisites¶
- Windows 10 Pro, Enterprise, or Education edition.
- WSL 2 enabled on your Windows machine.
- Docker Desktop for Windows installed.
Step-by-Step Guide¶
-
Install Docker Desktop for Windows:
- Download Docker Desktop for Windows from the official Docker website: https://www.docker.com/products/docker-desktop
- Run the installer and follow the instructions to complete the installation.
-
Enable WSL 2:
Enable docker for wsl2

-
Set wsl default version to 2:
- Open PowerShell as an administrator and run the following command:
-
Install a Linux Distribution:
- Open the Microsoft Store app on your Windows machine.
- Search for a Linux distribution (e.g., Ubuntu, Debian, or Alpine) and install it.
wsl installer

-
Configure WSL 2 as the Default WSL Version:
- see the list of distro you have
- Open PowerShell as an administrator and run the following command:
Replace
<distribution_name>with the name of the Linux distribution you installed. -
Start the Linux Distribution:
- Launch the Linux distribution you installed from the Start menu or by running its executable.
- Follow the initial setup instructions to create a user account and set a password.
-
Add the Docker host configuration:
- Scroll to the end of the file using the arrow keys.
- Add the following line:
- I didn't need this one but who knows:
-
Reload the updated
.bashrcfile:- Run the following command to apply the changes:
-
Verify Docker connectivity:
- Run the following command to check if the Docker client in WSL can connect to Docker Desktop:
-
Enable WSL Integration in Docker Desktop:
- Open Docker Desktop on your Windows machine.
- Right-click on the Docker Desktop icon in the system tray (notification area) and select "Settings".
- In the "Settings" window, navigate to the "Resources" section.
- Click on "WSL Integration" in the left sidebar.
- Toggle the switch next to your WSL distribution (e.g., Ubuntu) to enable integration.
- Click "Apply & Restart" to save the changes and restart Docker Desktop.
-
Verify Docker Connectivity in WSL:
- Open the WSL terminal (Ubuntu).
- Run the following command to check Docker connectivity:
That's it! You should now have Docker successfully configured and running on Windows 10 with WSL 2. You can now use Docker commands within your Ubuntu WSL terminal to manage containers, images, and other Docker resources.
If you encounter any issues or have further questions, feel free to ask. Happy Dockerizing!
basic commands for working with wsl 2¶
- install wsl:
wsl --install - check list of distro (name and version):
wsl.exe -l -v - change from v1 to v2:
wsl.exe --set-version Ubuntu 21 - unsinstall the wsl:
wsl.exe --unregister Ubuntu-22.04whereUbuntu-22.04is my distro name i got - see images
docker images