Install wsl in window11, connect wsl to vsCode development, install docker and Nginx

1、wsl

1.1. What is wsl

Official documentation of virtualization tools from Microsoft :

WSL 2 is a new version of the Windows Subsystem for Linux architecture that supports Windows Subsystem for Linux running ELF64 Linux binaries on Windows.

2. Recommended method to install wsl in windows 11

My win11 version
Insert image description here

2.1. Open the two functions of window and restart

  1. In Control Panel-Programs-Turn on or off window functions
    Insert image description here

  2. Check the corresponding function
    Insert image description here
    . After confirmation, you need to restart the computer.

2.2. Install Linux distribution

Search for wsl in the Microsoft Store, find the following icon, and download and install it.

After installation, enter wsl -l -v in powerShell to view the version.
Insert image description here
Note: What if a bunch of Ubuntu files appear when you open it? ? ? ? , just enter the following command in PowerShell to install the kernel, and then set the user name and password

wsl --update

Insert image description here

2.3. How to start Ubuntu

Method 1: Enter wsl directly in PowerShell to start
Method 2:

3. Use in conjunction with vsCode

3.1. Install wsl in vsCode toolkit

Insert image description here

3.2. The corresponding remote resource management icon appears in vscode.

Insert image description here

4. View the internal files of Linux in Windows 11

That is, Ubuntu’s internal file system
Insert image description here

5. Install docker in window11

Method 1: Install Docker Desktop in Windows (large memory consumption)
Method 2: Install Docker Engine in WSL (Ubuntu) (recommended)
Insert image description here

5.1. Install Docker Engine in wsL (Ubuntu)

  1. Open the official website
  2. Find the Ubuntu installation page for Docker Engine
  3. Follow the prompts and install using apt

Notice

The Ubuntu we installed does not come with Gul, so we installed Docker Engine instead of Docker Desktop

Official website location: https://docs.docker.com/engine/install/ubuntu/After
Insert image description here
successful installation

5.2 Install nginx

// Ubuntu 中安装nginx
docker pull nginx:latest
docker run --name ng -dp 8080:80 nginx:latest
// 启动docker
sudo service docker start

Insert image description here
Official website of nginx: https://hub.docker.com/_/nginx
You can download the image of the desired version

Guess you like

Origin blog.csdn.net/wang13679201813/article/details/127682185