iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🐧

Trying the Simplified WSL Installation for Windows Insider on Windows 10

に公開

Addendum: Here are the steps for the Windows 11 environment.

https://zenn.dev/15/articles/ca6b199b5a8a9f


While it requires installing a preview build beforehand, except for the wait time during installation and reboots, you can now set up everything from starting nginx to Docker integration in an instant.

To use the simplified install command wsl --install, you must join the Windows Insider Program and install a preview build of Windows 10 (OS build 20262 or later), but you will no longer need to follow manual installation steps.

https://docs.microsoft.com/en-us/windows/wsl/install-win10

Installation

Run the Command Prompt as an administrator and execute the following command to install WSL2 (Ubuntu 20.04).

wsl --install

You will be asked to restart during the process.

After the restart, a message like "Installing Ubuntu" will appear in the Command Prompt; press Enter. (I thought it would proceed if I left it alone, but it seems input is required.)

Enter the username and password as prompted to finish.

Terminal Setup

Install Windows Terminal from the Microsoft Store and launch it.

Configuring via GUI

I remember having to edit JSON in the past, but it now supports configuration via a GUI.
Open the settings screen with Ctrl + , or from the taskbar.

Startup Settings

The Default Profile is set to Command Prompt, so change it to Ubuntu.

Ubuntu Profile Settings

Select Ubuntu from the left menu of the settings screen.

Changing the Home Directory in Ubuntu General

The Ubuntu > General section will be displayed.

By default, the Starting Directory is set to the Windows home directory, so change it to the Ubuntu-side home, such as \\\\wsl.localhost\\Ubuntu\\home\\johndoe.

Display Settings in Ubuntu Appearance

Open Ubuntu > Appearance.

Change the Color Scheme to Solarized Dark and the Font face to Consolas or similar, according to your preference.

Restarting the Terminal

Exit the Terminal and restart it to apply the above settings.

Trying out nginx

sudo apt update
sudo apt install nginx

Install nginx with the commands above.

Prepare a simple HTML file with sudo vi /var/www/html/index.html and run sudo nginx.

Open http://localhost/ in your Windows browser to see the HTML displayed.

Since we won't need nginx on Ubuntu from now on, remove it with sudo apt remove nginx.

Enabling Docker commands on the Ubuntu side

Install Docker Desktop for Windows.
Ensure that "Install required Windows Components for WSL2" is checked during installation.

Skip the initial tutorial, as following it directly will execute it in the Windows Command Prompt.

Settings

Enable Ubuntu under Settings > Resources > WSL INTEGRATION > Enable integration with additional distros: and restart.

Getting Started

Launch the Terminal, run docker run -dp 80:80 docker/getting-started, and open http://localhost/ to see the Getting Started page.

Discussion