We know that Docker needs WSL to run. When you freshly install a Docker instance, the Docker service may not be started successfully because of lacking WSL(Windows Subsystem for Linux). However, win10 has WSL as an optional feature and will not activate it as default. Therefore, you have to enable the feature and install the WSL update package manually. The following five steps will guide you to enable WSL 2 on your OS successfully, thereby getting the Docker service started up.
Note:
We will use windows command(PowerShell) terminal for enabling WSL. You'd better to open a terminal as administrator to get enough permission to execute the commands.
Step 1. Enable The Win10 Subsystem for Linux
We can install a Linux distribution only when the feature "Microsoft-Windows-Subsystem-Linux" has been activated on the OS. The following command will activate the feature.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Step 2. Prerequisite of WSL 2 Install
After the subsystem of Linux feature has been activated, you have also to check your windows10 to make sure the OS is eligible for installing WSL 2.
- For x64 systems: Version 1903 or higher, with Build 18362 or higher.
- For ARM64 systems: Version 2004 or higher, with Build 19041 or higher.
- Builds lower than 18362 do not support WSL 2. Use the Windows Update Assistant to update your version of Windows.
Step 3. Enable Virtual Machine Feature
Besides we have to enable the Hyper Virtualization technology on BIOS, we also need to enable this Virtualization optional feature on Windows 10 as well. You may follow the following command to enable it.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Step 4. Install Linux kernel update package
You may download the installation package from here: WSL 2
Step 5. Set WSL 2 as default
Set version 2 of the WSL as default by the following command.
wsl --set-default-version 2
Verification
If you get success in all the steps listed above, you should be able to start up the Docker service right now.
References
Craig Loewen, Matt Wojciakowski, Amir H., Muhammad Atif Ali, David Coulter, Max Calvin, Michael Satran, Mera Gangapersaud, Aleksandar Nikolić, Tara Raj, & Rich Turner. (2021, September 12). Manual installation steps for older versions of WSL. Https://Docs.Microsoft.Com/En-Us/Windows/Wsl/Install-Manual. Retrieved December 18, 2021, from https://docs.microsoft.com/en-us/windows/wsl/install-manual