5

Running Windows 10 (ver 21H1 19043.1415).

I enabled the required Windows WSL features some time ago. Since then, I've switched back and forth between WSL1 and WSL2 several times with Linux packages.

I've used Docker for some time. It seems Docker's recent updates transitioned Docker from WSL1 to WSL2 on Windows.

Ubuntu was just uninstalled from the PC. The status of WSL was checked:

wsl --list --verbose

The returned status shows:

NAME STATE VERSION
docker-desktop-data Stopped 2
docker-desktop Stopped 2

Question: Can the Windows subsystem version of Linux, Ubuntu 20.04, be installed as WSL1? Which means the PC has both WSL1 and WSL2 active?

3
  • 2
    Docker never used WSL1
    – Ramhound
    Commented Jan 3, 2022 at 9:51
  • 1
    wsl --set-version is covered in multiple Super User questions and answers already, and really doesn't need a separate Community Wiki answer. Check out (among others), Do I need to reinstall Ubuntu after installing WSL 2? Commented Jan 3, 2022 at 14:27
  • Ramhound is correct. Docker Engine could not run directly inside WS1L. One of the more recent Docker upgrades mentioned Docker would now be operating in WSL2. I wrongly assumed Docker had been operating in WSL1. It hadn't. Upon reading up on the subject it was mentioned that the Docker Engine couldn't run directly inside WSL, so the Docker team developed an alternative solution using Hyper-V VMs and LinuxKit.
    – Gray
    Commented Jan 5, 2022 at 1:32

1 Answer 1

7

Yes. Windows 10 can have both WSL1 and WSL2 active.

After exploring the Basic Commands for WSL at Microsoft I learned the Windows sub-system version of Linux can be easily converted from WSL1 to WSL2 or Vice versa.

https://docs.microsoft.com/en-us/windows/wsl/basic-commands

Below demonstrates how Ubuntu (or other distros) can be converted from WSL1-WSL2 and back and forth. All commands were commands given in the Windows Terminal (the new PowerShell). The PowerShell command(s) to convert are:

wsl --set-version ubuntu 1
wsl --set-version ubuntu 2

Ubuntu was (just) reinstalled (again) from the Microsoft Store. The User name and Password were created. No sudo update/upgrades were done (yet). The WSL status was checked and showed the newly installed (running) Ubuntu was installed as WSL2.

PS C:\Users\prior> wsl --list --verbose
NAME STATE VERSION
docker-desktop-data Stopped 2
docker-desktop Stopped 2
Ubuntu Running 2

Then Ubuntu was converted from WSL2 to WSL1. The status was checked again. This showed Ubuntu converted to WSL1 and stopped.

  PS C:\Users\prior> wsl --set-version ubuntu 1

Conversion in progress, this may take a few minutes... Conversion complete.

  PS C:\Users\prior> wsl --list --verbose
NAME STATE VERSION
docker-desktop-data Stopped 2
docker-desktop Stopped 2
Ubuntu Stopped 1

Ubuntu was restarted from the Windows start apps list. The WSL status was checked again. The status returned showing Ubuntu was running as WSL1. The Docker apps were still WSL2.

PS C:\Users\prior> wsl --list --verbose
NAME STATE VERSION
docker-desktop-data Stopped 2
docker-desktop Stopped 2
Ubuntu Running 1

Docker was started and the WSL status checked. It becomes clear that both WSL1 and WSL2 files can be active and running in Windows 10.

PS C:\Users\prior> wsl --list --verbose
NAME STATE VERSION
docker-desktop-data Running 2
docker-desktop Running 2
Ubuntu Running 1

Then for the sake of curiosity, Ubuntu was converted back to WSL2 and then started. The status was checked and showed the conversion to WSL2 worked. Ubuntu and Docker are WSL2 and running.

PS C:\Users\prior> wsl --set-version ubuntu 2

Conversion in progress, this may take a few minutes... For information on key differences with WSL 2 please visit https://aka.ms/wsl2 Conversion complete.

PS C:\Users\prior> wsl --list --verbose
NAME STATE VERSION
docker-desktop-data Running 2
docker-desktop Running 2
Ubuntu Running 2

It seems clear that it was unnecessary to uninstall and reinstall Linux whenever switching the sub-system for WSL1 or WSL2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .