[2023 latest version] Win11: WSL (Ubuntu22.04) using docker remote container tutorial (Windows Docker Desktop download and installation, migration to non-system disk, configure domestic mirror source, set up WSL2)

Table of contents

1. Preparation work

1. Install WSL (Windows Subsystem for Linux)

2. Introduction to docker - source chatGPT

2. Install Docker Desktop on Windows

1. Official website link

2. Installation process

3. Migrate to non-system disk

4. Configure domestic mirror source

Domestic mirror

Method 1 - Configuration via Docker-Desktop

Method 2 - Find the daemon.json file for configuration

3. Set up WSL 2 on Docker Desktop for Windows

1. Start the WSL 2-based engine

2. Select WSL 2 distribution

3. Test

4. Commonly used commands


1. Preparation work

1. Install WSL (Windows Subsystem for Linux)

Windows 11 installation of Linux subsystem (Ubuntu22.04LTS) + installation of ROS_QomolangmaH's blog-CSDN blog icon-default.png?t=N7T8https://blog.csdn.net/m0_63834988/article/details/128672234?spm=1001.2014.3001.5501

2. Introduction to docker - source chatGPT

        Docker is a containerization platform that allows you to package an application and all of its dependencies into a standard unit called a container. Key features of Docker containers include:

  1. Isolation - Docker containers are isolated from each other, wrapping their own file systems, CPU registers, process trees, network stacks, etc. This makes them more portable and consistent.
  2. Resource Efficiency - Docker containers share the operating system kernel with other containers, making them more lightweight than virtual machines.
  3. Repeatability - Docker containers use images as templates to create an exact copy of your environment. This ensures consistency during deployment.
  4. Speed ​​- Docker containers start very fast, measured in seconds instead of minutes.
  5. Portability - Docker containers can be moved across any computing infrastructure that supports the Docker platform.
  6. Scalability - You can run multiple Docker containers on a single machine, utilizing all CPU cores and memory.
  7. Loosely coupled - Docker containers are self-contained units that are not dependent on the environment in which they run.

In short, Docker allows you to package and reliably run applications in a portable and standardized container format.

2. Install Docker Desktop on Windows

1. Official website link

Download Docker Desktop | Dockericon-default.png?t=N7T8https://www.docker.com/products/docker-desktop/

2. Installation process

  • download

  • Double click to install

  •  Restart after successful installation

  • Select accept

  •  You can choose not to log in

  • You can choose to skip

3. Migrate to non-system disk

  • Find the directory in the C drive and move it to the location you want to install.

        Note that you must delete the Docker folder in the C drive

  • Same as above, move the file and delete the file in the C drive (if it prompts that it cannot be deleted, restart the computer)

  • Open cmd with administrator rights and enter the following command
mklink /J "C:\Program Files\Docker" "E:\Software\Docker"
mklink /J "C:\Users\Lenovo\AppData\Local\Docker" "D:\Users\Lenovo\AppData\Local\Docker"

         If you don’t have administrator rights:

         With administrator rights:

4. Configure domestic mirror source

Domestic mirror

  • Docker China official image
https://registry.docker-cn.com
  • University of Science and Technology of China
https://docker.mirrors.ustc.edu.cn
  •  NetEase

http://hub-mirror.c.163.com
  • Tencent
https://mirror.ccs.tencentyun.com
  • Alibaba Cloud containers generate their own acceleration addresses

Container Mirror Service (aliyun.com) icon-default.png?t=N7T8https://cr.console.aliyun.com/cn-qingdao/instances/mirrors

Method 1 - Configuration via Docker-Desktop

 "registry-mirrors":[
        "https://docker.mirrors.ustc.edu.cn",
        "https://registry.docker-cn.com",
        "http://hub-mirror.c.163.com",
        "https://mirror.ccs.tencentyun.com"
   ]

Method 2 - Find the daemon.json file for configuration

3. Set up WSL 2 on Docker Desktop for Windows

        Docker for Windows has two running modes, one runs Windows-related containers and the other runs traditional Linux containers. Only one mode can be selected to run at the same time.

1. Start the WSL 2-based engine

        Check "Use WSL 2-based engine" in Settings > General (on by default)

a. How to open WSL terminal

b. View docker version and build number

docker --version

docker info

c. Check WSL mode

wsl.exe -l -v

Upgrade your Linux distribution to v2:

wsl.exe --set-version (distro name) 2

To set v2 as the default version for future installations, run:

wsl.exe --set-default-version 2

2. Select WSL 2 distribution

        Settings > Resources > WSL Integration, select from the installed WSL 2 distribution you want to enable Docker integration for

3. Test

docker run hello-world

4. Commonly used commands

  • List the commands available in the Docker CLI by entering:
docker
  • Use the following command to list information for a specific command:
docker <COMMAND> --help
  • Use the following command to list the docker images on your computer (only the hello-world image at this time)
docker image ls --all
  • Use the following command to list the containers on your computer
docker container ls --all

 or (without the -a show-all flag, only running containers are shown)

docker ps -a
  • Use the following command to list system-wide information about your Docker installation, including statistics and resources (CPU & Memory) available to you in the context of WSL 2:
docker info

Guess you like

Origin blog.csdn.net/m0_63834988/article/details/131816239