I will leave the details of WSL2 etc. to other people, but for the time being I tried to summarize the things that got stuck in the installation etc.
I was in trouble without checking the procedure properly, so I will write some things that I was in trouble after the official procedure. (Everyone is encouraged to read the documentation properly)
The details will be in English Docs, but I think you should take a look at the official version. If you are interested in reference materials, please check only the items in the reference materials at the bottom.
You need to check the build version of Windows.
Open Run from Command in windows + R and enter the following command.
winver
It will be displayed as follows.
Make sure the value for this version is 1903 or higher. (This number will be relevant later.)
I have prepared an English link below, but please do not translate it into Japanese. Because, at present (as of September 23, 2020), the English document has been updated first, so the content is slightly different from the Japanese one. Maybe there was a recent update and I haven't updated it in Japanese yet (the English version was updated on 9/15/2020).
https://docs.microsoft.com/en-us/windows/wsl/install-win10
Open Power Shell with administrator privileges and execute the following command. The following command enables WSL.
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
(Maybe you need to reboot here first) Then enable the "Virtual Machine Platform" optional feature.
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Now restart your PC.
Drop the msi file from the link below and run it to update the Linux kernel. (If this is Japanese docs, it wasn't new yet, so I got stuck)
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
Finally, set the default version of WSL to WSL2.
wsl --set-default-version 2
The WSL that will be added later may be WSL2.
Put Ubuntu in the Microsoft Store.
I think you can choose from the three on the left. I'm using Ubuntu-20.04 here. There is no particular reason.
Let's install the extension.
Right-click on the desired linux (downloaded from the Microsoft Store) and select "connect WSL".
It looks like something went wrong.
After that, the operation on the WSL side was done from here.
We will proceed according to the following. https://docs.docker.com/docker-for-windows/wsl/
Run the winver command as you did at the beginning to install the Docker Desktop for each version. --1903 and above: Edge version --2004 and above: Stable version
Download site https://hub.docker.com/editions/community/docker-ce-desktop-windows/
Go to the General page from Settings.
Check Use WSL 2 based engine and Apply & Restart.
Make settings such as WSL integration. Apply & Restart by turning on the following items from the Docker Desktop settings.
When I connected with VSCode, I was able to hit the docker command safely!
The errors that I caused as a result of not completely following the official order by touching it a little before (laugh)
In the first place, there were times when the wsl command did not pass. Especially when fixing it, I didn't mess with the environment variable path. When I restarted it or re-entered the command, the command passed. So maybe I just missed some steps.
It was wsl (1) and I couldn't type the docker command. (Because I missed the procedure) If you open Powershell with administrator privileges on the original machine and type the following command
wsl -l -v
I knew the version like this.
If the target WSL is ver1, use the following command to raise ver.
wsl --set-version Ubuntu-20.04 2
The above command sets Ubuntu-20.04 to WSL2 (see image above).
After all, it is difficult (for me who does not read properly) to do it in order. I wrote a little about what happened when that happened.
This time, the elements VSCode, Docker Desktop, and WSL2 are involved. So, when an error occurred, it was important to check from which one. You're probably getting some kind of error, so don't panic and check the error message. (Specifically, this time it led to checking from the error message that the version of wsl is different, etc.)
After all, I felt that there were many mistakes in my procedure in the pattern where an error occurred by referring to the formula related to such construction. So, I felt that it was somehow effective to check from the error message to see if something was missing, or to start over from the beginning of the procedure.
If there is still no information, I felt that it would be better to search the Web with a separate error message.
Recommended Posts