In windows 10 you can now setup Docker Desktop with Linux container, without using a virtual machine for Linux, by using Windows Subsystem for Linux (WSL). Remembering all manual steps for doing this is bit cumbersome, and therefore let’s look at how we can use PowerShell to automate the task of installing Docker Desktop with WSL version 2, on Windows 10.
The PowerShell script to install Docker Desktop with WSL2 s available here.
Let’s try to understand each part of the script.
As the first step the script ensures it runs on administrator PowerShell widow. Then we are setting download progress etc. to silent as it will consume much more time to download installers, if progress is shown while running the script.
Next, step is to check if Hyper V is enabled in the machine. If not it will be enabled and system reboot will be prompted.
Once the machine is restarted rerunning the script will check if WSL is installed in the machine and will install WSL. We have to reboot the machine once installation is done.
Once rebooted, as the next step the script will install WSL Linux kernel update if the machine is a 64 bit. Then the WSL will be set to use version 2.
Next, Docker Desktop will be downloaded and installed. A reboot will be prompted. Here instead of reboot you can log off and log on to machine manually and the Cocker Desktop will start to run.
However, after a reboot if you run the script again it will wait for Docker engine to start on the machine and confirms once it is started.
Docker will run with WSL2.
No comments:
Post a Comment