This isn’t anything ground breaking but something that is really awesome for those that run SQL Server on Linux using Docker Desktop for Windows, Windows 10 (SDK version 2004, Build 19041 or higher) now ships with Windows Subsystem for Linux (WSL) 2.

I won’t go too much into what this is as you can read the article in the links above but to summarise, this will improve the experience of docker on windows:

  • Improvements in resource consumption
  • Starting up docker daemon is significantly quicker (Docker says 10s as opposed to ~1min previously)
  • Avoid having to maintain both Linux and Windows build scripts
  • Improvements to file system sharing and boot time
  • Allows access to some cool new features for Docker Desktop users.

Some of these are improvements we’ve been crying out for over the last couple of years so in my opinion, they’re a very welcome addition.

In order to get started using WSL2, there’s a couple of steps you need to run through which I’ll try and show below with a few screen shots.

Downloads

Process

Before we can do anything, please make sure that you have the downloads from the link in the previous section

Install Docker Desktop

Nothing to report on here, fairly straight forward click, click click

nstalling Docker Desktop 23.0.4 (46911) 
Docker Desktop 2.3.0.4 
Installation succeeded 
Close

Once installed, depending on what the state of you machine is currently, you may see this message regarding installing WSL2:

Docker Desktop - Install WSL2 
WSL 2 is not installed 
Install WSL using this powershell script (in an administrative powershell) and 
restart your computer before using Docker Desktop: 
Enable-WindowsOptionalFeature -Online -FeatureName 
"Microsoft-Windows-Subsystem-Linuk') 
Use Hyper-V Stop Docker

Simply follow the information and enable the optional feature either using the powershell provided:

Enable-WindowsOptionalFeature -Online -FeatureName $("VirtualMachinePlatform", "Microsoft-Windows-Subsystem-Linux")
PS C: \WINDOWS\system32> Enable-WindowsOptiona1Feature 
-Online 
-FeatureName 
"Virtua1MachineP1atform", "Microsoft-Windows-Subsystem-Linux" 
Path 
nline 
RestartNeeded 
True 
False

Or you can go to the windows features and enable it manually:

Windows Features 
Turn Windows features on or off 
O 
To turn a feature on, select its check box. To turn a feature off, clear its 
check box. A filled box means that only pat of the feature is turned on. 
D TFTP Client 
Z] Virtual Machine Platform 
Windows Hypervisor Platform 
Windows Identity Foundation 3.5 
Z] Windows PowerSheII 2.0 
Windows Process Activation Service 
Windows Projected File System 
Windows Subsystem for Linux 
Windows TIFF Filter 
Work Folders Client 
Cancel

Once you have done this you will be prompted to install the Linux Kernel update package (See downloads). You can reboot before doing this (another reboot may be required after) but I managed to install it and just do a single reboot:

Docker Desktop - Install WSL 2 kernel update 
WSL 2 installation is incomplete. 
The WSL 2 Linux kernel is now installed using a separate MSI update package. 
Please click the link and follow the instructions to install the kernel update: 
https://aka.ms/ws12kernel. 
Press Restart after installing the Linux kernel.
Need to run the Linux kernel update and restart
Windows Subsystem for Linux Update Setup 
Welcome to the Windows Subsystem for Linux 
Update Setup Wizard 
The Setup Wizard will install Windovvs Subsystem for Linux 
Update on your computer. Click Next to contnue or Cancel 
to exit the Setup Wizard.
Run the update executable

Takes about 2 seconds to update

Windows Subsystem for Linux Update Setup 
Completed the Windows Subsystem for Linux 
Update Setup Wizard 
Click the Finish button to exit the Setup Wizard.
Update now complete

Depending on your setup, there may be a couple of additional steps if you follow this link:

Checking

Open the Docker settings and you should now see the option to use the WSL 2 based engine:

Select it and restart docker

If you wish to see what version of WSL you have then you can run the command below in an elevated command prompt:

wsl --list --verbose

I already have the Ubuntu distribution installed so I didn’t have to do this, you may need to install this:

If you click launch then the dstro will start:

Run SQL Server on Linux

docker run 	-e "ACCEPT_EULA=Y" `
				-e "SA_PASSWORD=P@ssword1" `
				--cpus="2" `
				--name SQLLinuxLocal -d `
				-p 1433:1433  `
        		<<Put Your Image Name here>>
docker ps -a

I can’t say too much about the various performance improvements so far but the daemon startup is certainly a lot quicker than previously. Perhaps some testing of the performance is in order and another blog post……. 😜

Links