Article directory
Replace domestic sources
Due to network problems, it is generally necessary to use domestic sources to speed up image downloads. After installing docker destop, you can modify the image source through the following four steps
[1-Settings] -> [2- Docker Engine] -> [3-Modify source] -> [4- Apple & restart]
Modify the source specifically and need to add The following content
"registry-mirrors":[
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com",
"https://docker.mirrors.ustc.edu.cn"
],
Domestic mirror sources can be used after restarting
Change image storage location
PS: All the following operations are run in powershell
Docker Desktop is installed on the C drive by default, and the default image storage location isC:\用户\Administrator\AppData\Local\Docker\wsl\
To reduce C drive storage consumption, you can migrate storage locations such as images to other drives.
Docker Desktop is started through WSL2 and will automatically create 2 subsystems, corresponding to 2 vhdx hard disk image files. You can see
the executablewsl --list -v
$ wsl --list -v
NAME STATE VERSION
* docker-desktop Running 2
docker-desktop-data Running 2
Migration steps
- On the Docker Desktop icon, right-click and select [Quit Docker Desktop] to exit Docker
- Command line execution
wsl --list -v
Check the status STATE to see if it is Stopped
$ wsl --list -v
NAME STATE VERSION
* docker-desktop Stopped 2
docker-desktop-data Stopped 2
- Command line execution
wsl --shutdown
, close WSL - To export the image from wsl
\data\ext4.vhdx
to a compressed filedocker-desktop-data.tar
, the export path should be created in advance, otherwise an error will be reported when exporting to a non-existent path. Command line execution
wsl --export docker-desktop-data "D:\\Docker\\wsl\\data\\docker-desktop-data.tar"
In the same way, export the program\distro\ext4.vhdx to the compressed file docker-desktop.tar, and execute it on the command line
wsl --export docker-desktop D:\Docker\wsl\distro\docker-desktop.tar
- Execute
wsl --unregister docker-desktop-data
to unregister the original Docker image. Likewise, executewsl --unregister docker-desktop
. Note that the ext4.vhdx file will be automatically deleted after execution. - From the tar file, import the exported Docker image back to wsl, and set the mounting directory. The command line import format is:
wsl --import <Distribution Name> <InstallLocation> <FileName> --version 2
wsl --import docker-desktop-data "D:\Docker\wsl\data\" "D:\\Docker\\wsl\\data\\docker-desktop-data.tar" --version 2
wsl --import docker-desktop "D:\Docker\wsl\distro\" "D:\\Docker\\wsl\\distro\\docker-desktop.tar" --version 2
After execution, you can see the new ext4.vhdx file
- Restart Docker Desktop Done
Command summary
# 查看
wsl --list -v
# 关闭
wsl --shutdown
# 导出
wsl --export docker-desktop-data "D:\\Docker\\wsl\\data\\docker-desktop-data.tar"
wsl --export docker-desktop "D:\\Docker\\wsl\\distro\\docker-desktop.tar"
# 注销
wsl --unregister docker-desktop-data
wsl --unregister docker-desktop
# 导入
wsl --import docker-desktop-data "D:\Docker\wsl\data\" "D:\\Docker\\wsl\\data\\docker-desktop-data.tar" --version 2
wsl --import docker-desktop "D:\Docker\wsl\distro\" "D:\\Docker\\wsl\\distro\\docker-desktop.tar" --version 2
Modify configuration and change mirror location (verification failed)
Modify the red box position in the settings. I tried and found that it did not take effect. The reason is unknown.