My Win10 has finally enabled WSL2 on the last Windows Update.
Let's make Docker compatible with WSL2 immediately according to the official procedure https://docs.docker.com/docker-for-windows/wsl/
WSL is an abbreviation for Windows Subsystem For Linux You can think of it as something that allows you to use Linux commands on the Windows command line.
WSL2 is version 2 of WSL. However, it is not fully upward compatible with WSL1 and has advantages and disadvantages. https://docs.microsoft.com/ja-jp/windows/wsl/compare-versions
The Linux OS used for WSL is Ubuntu for versatility. The file size is large, but I think it is the most recommended for WSL. https://www.microsoft.com/ja-jp/p/ubuntu/9nblggh4msv6?activetab=pivot:overviewtab
If it is left as it is, it will be installed by WSL1, so let's update to WSL2.
#Check installed WSL and version
wsl -l -v
NAME STATE VERSION
* Ubuntu Running 1
The default WSL is marked with *
. If you have multiple Linux in WSL, you will get a lot.
Normally, the default WSL is integrated with Docker.
#Upgraded WSL
wsl --set-version Ubuntu 2
#Double-check the installed WSL and version
wsl -l -v
NAME STATE VERSION
* Ubuntu Running 2
If the Ubuntu version is 2, you are successful.
Go to Settings> General
and check ʻUse WSL 2 based engine ʻApply & Restart
Settings> Resources> WSL Integration
The integration function is enabled in the default WSL.
Now, Docker, which used to run on virtual machines on Hyper-V, now runs on WSL2.
Although WSL2 is now fully Linux, it has the disadvantage of slowing performance with Windows file sharing. As a result, if I shared a local Windows folder to a container with volumes, it would feel quite slow.
If you share the area under / mnt / c /
which is the shared area of wsl with Windows with volumes, it will be slow, so
Put your program code somewhere else.
The official best practices also say so.
https://docs.docker.com/docker-for-windows/wsl/#best-practices
https://docs.docker.com/docker-for-windows/wsl/#develop-with-docker-and-wsl-2
If you execute the code
command in WSL, VS Code of Windows will open in Remote-WSL mode! !! !!
code ~/hoge_workspace/
After that, prepare devcontainer.json
in the folder in WSL and follow the usual procedure Reopen in Container
-Develop on Docker on remote host with VS Code -Building the fastest development environment using Haskell extension of VS Code
You can access the folders in WSL with Explorer by accessing the following network path while Linux in WSL is running. You can also edit the file from Windows as it is.
\\wsl$\
Recommended Posts