Windows Subsystem for Linux (WSL) is a great tool to have access to all your NIX tools and even run more Linux native solutions on the Windows platform. WSL 2 is the updated version of WSL with more features and represents the more recent implementation of the WSL solution. WSL and WSL 2 is a great tool for developers and DevOps pros alike to be able to natively have these tools on their Windows Workstations without having to run a separate development VM for this purpose. One of the tools you probably want to install and run in WSL is Docker. Docker is of course the container platform of choice for most organizations and provides a great platform for running containers in testing, development, and production environments. How do you get Docker running in WSL 2? Let’s step through the process Install Docker on Windows Subsystem for Linux WSL 2 in Windows 10 and see what if any hurdles are encountered getting up and running with containers in WSL 2.
Install Windows Subsystem for Linux WSL 2
The first step of course if we are going to run Docker containers inside of Windows Subsystem for Linux WSL 2 is to actually install WSL 2. The steps to that are straightforward and well-documented in the official KB from Microsoft. However, below are screenshots of walking through that documented process to get up and running with WSL 2.
- Install Windows Subsystem for Linux
- Install the Virtual Machine Platform on Windows 10
- Reboot
- Download and install the Linux Kernel update package
- Set the default version to WSL 2
1. Install Windows Subsystem for Linux
This can easily be done through a PowerShell prompt with the following command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
2. Install the Virtual Machine Platform on Windows 10
The next step is to install the Virtual Machine Platform on Windows 10. Again, in a PowerShell prompt, run the following command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
3. Reboot
Reboot your Windows 10 workstation to instantiate the components correctly. You will see “Windows Updates” applying after making the changes.
4. Download and install the Linux Kernel update package
Do this here:
5. Set the default version to WSL 2
The next step is to set the default WSL version to WSL 2. This is easily done with the command below:
wsl --set-default-version 2
Download and install the Ubuntu App
There are several flavors of Linux found in the Microsoft Store for running in WSL 2. For this walkthrough, I will be using the Ubuntu App. You will see several options here. In the Microsoft Store, you will see specific versions of Ubuntu listed which you can download. You can also choose the Ubuntu app. This installs the latest version available in the store and then will update when a new version is available.
After installing the Ubuntu app, launch the app to perform the initial setup of your WSL 2 environment – setting user password, etc.
Install Docker on Windows Subsystem for Linux WSL 2 Windows 10
Now for the part we have been waiting for, installing Docker. Just like any Ubuntu distribution, you can install Docker from the command line.
However, if you attempt to run any Docker commands outside of simply running the “docker” command to display the parameters, you will see the error below:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
Installing Docker Desktop for WSL 2 integration
In order to get Docker running correctly inside your WSL 2 environment, you need to install Docker Desktop along with the required Windows components for WSL 2. Download Docker Desktop for Windows here:
After you install Docker Desktop, you can verify the integration with your default WSL distro is enabled under the Settings > Resources > WSL Integration section.
Running Docker Containers in WSL 2
Now, when you run Docker commands from your WSL environment, they will be successful. Having the Docker Desktop integration configured allows successfully running Docker command line tools.
As you can see below, you can now spin up Docker containers from WSL 2.
It also provides the added benefit of additional tooling to work with your Docker containers via the Docker Desktop.
Wrapping Up
The process to install Docker on Windows Subsystem for Linux WSL 2 Windows 10 is a process that involves getting WSL 2 installed and installing Docker Desktop for Windows along with the WSL 2 integration. Once you have the integration installed, Docker commands will work natively inside the WSL 2 environment.
1 Comments
Install Docker On Windows Subsystem For Linux Wsl 2 Windows 10 >>>>> Download Now
ReplyDelete>>>>> Download Full
Install Docker On Windows Subsystem For Linux Wsl 2 Windows 10 >>>>> Download LINK
>>>>> Download Now
Install Docker On Windows Subsystem For Linux Wsl 2 Windows 10 >>>>> Download Full
>>>>> Download LINK WZ