Build a modern development environment using WSL2 (Windows Subsystem for Linux ver2), Visual Studio Code (hereinafter VSCode), and Docker Desktop, which can build a Linux environment on Windows.
--Developers on Windows --People who are developing with Docker, people who want to go from now on --I don't do cmd. Use bash, people
WSL2 could only be installed on Windows 10 version 2004 (May 2020 Update) or later, but since 2020/8 it can also work on 1903/1908.
["WSL 2" is now available for "Windows 10 version 1903/1909" -Microsoft ported to older OS-Window Forest](https://forest.watch.impress.co.jp/docs/news/ 1272017.html)
The following are common tasks for 1903/1908/2004.
Open the control panel.
Open "Turn Windows features on or off".
Check "Windows Subsystem for Linux" and press the OK button.
You will need to reboot after the installation is complete.
This is a Linux-only environment setup that requires a CentOS or Ubuntu distribution.
You can download it directly from the Windows Store.
If you start the Windows Store and search for Ubuntu, it will appear, so you won't get lost.
If you cannot use the Windows Store in a company environment, you can download it from the following site.
Please select Ubuntu.
You can install it by clicking the downloaded file.
When the installation is complete, the Ubuntu terminal will launch.
First, decide on your Linux username and wasword. Please put any one.
The shell will start and be ready for use. Leave the terminal as it is.
If VSCode is not included, please enter it from the following.
Start VSCode and search for wsl from the extension.
(In the image below, it is already installed)
Once installed, close VSCode once.
Select [Ubuntu] from the Windows Start menu to start the terminal.
Create an empty directory here and start VSCode there.
mkdir sample cd sample code .
VSCode will start. Launch a terminal (ctrl + @, ctrl + `for US keyboards) and make sure the shell is bash.
If you want to open an existing git project from VSCode, you need to download it with the git clone command.
Also, as will be described later, Ubuntu files can also be referenced in Explorer, so
From Ubuntu, you can also access Windows files by accessing
/ mnt / c /.
However, launching with VSCode's Remote feature under this will result in poor performance and the inability to monitor files, causing problems with behavior such as when files are added or modified.
If you want to use the Remote function of VSCode, create it under your home directory (accessible with
You can browse Ubuntu files by accessing
\\ wsl $ \ Ubuntu \ from Explorer.
You can continue to use Tortoises git.
Docker Desktop now supports WSL2. However, 1903/1908 is supported with the intention of
184.108.40.206 in the Early Access version (Edge), and is not supported in the stable version (Stable). (As of 2020-09-30)
The advantage of running on WSL2 is improved performance, especially faster container construction and startup. In addition, the performance improvement can be felt even with the docker datamon startup when the PC is started and the remote function of VSCode.
During the installation, you will be asked if you want to use WSL2 and press Yes.
From the [Docker] menu, select [Setting]> [General], and check [User the WSL2 base engine] there.
Click Apply & Restart to save and restart Docker Desktop.
In the Ubuntu shell, run the command
docker version to see the Docker information.
You can launch VSCode on Ubuntu and from there you can launch Docker in Remote Containers and connect.
For system development, a shell such as Bash is convenient, and macOS is often used as the development environment. Docker Desktop also has poor performance on Windows.
By using WSL2, you can easily prepare a Linux environment in Windows, and the performance performance is higher than using Hyper-V etc. In addition, WSL allows you to switch the environment according to your development project.
Until now, if you've only used Windows, you'll need to learn Linux, but when you're involved in development, you'll often find yourself stuck in Linux. Isn't it okay to use this as a trigger for learning?