Windows Docker Desktop自定义安装路径,非C盘
背景
\quad\quad
Windows Docker Desktop Installer
安装时,并没有给选择安装路径的选项。而我们的C
盘空间又“寸土寸金”,这该怎么办呢?
\quad\quad
当然可以参考这位博主Windows 10 Docker默认存储位置更改来手动更改.vhdx
虚拟镜像文件的挂载位置。但其实我们可以在安装时便指定位置,避免再费一次功夫。
资源准备
WSL2的非系统盘安装
\quad\quad
由于Windows Docker Desktop
默认的backend
后端已经是wsl2
了,因此,首先我们要有wsl
环境。
\quad\quad
参考wsl安装到非C盘解决方案 - 云中志的文章 - 知乎以及自定义WSL的安装位置,别再装到C盘啦 - Locietta的文章 - 知乎,直接在安装时便可以将wsl
安装到非系统盘,不需要再用wsl --export
来回搬了!
Docker Desktop Installer
\quad\quad
由于Docker
官网被墙,安装包不好下载,因此我把安装包放在一个百度云盘上——百度云盘Docker下载链接,提取码为dock
。
解决办法
\quad\quad
如果我们在命令行种,执行"Docker Desktop Installer.exe" --help
,我们可以看到如下的输出
"Docker Desktop Installer.exe" install [--quiet] [--accept-license] [--backend=wsl-2 | --backend=hyper-v | --backend=windows] [--allowed-org=<org name>]
--quiet Suppresses information output when running the installer
--accept-license Accepts the Docker Subscription Service Agreement now, rather than requiring it to be accepted when the application is first run
--no-windows-containers Disables Windows containers integration
--allowed-org=<org name> Requires the user to sign in and be part of the specified Docker Hub organization when running the application
--backend=<backend name> Selects the default backend to use for Docker Desktop, hyper-v, windows or wsl-2 (default)
--always-run-service Keep service always running, so regular users can switch to windows containers or hyper-v without being prompted for admin rights
--installation-dir=<path> Changes the default installation location (C:\Program Files\Docker\Docker)
--hyper-v-default-data-root=<path> Changes the default hyper-v VM disk location
--windows-containers-default-data-root=<path> Changes the default windows containers data root
--wsl-default-data-root=<path> Changes the default wsl data location
--admin-settings=<json> Used as admin settings for hardened desktop (needs to use --allowed-org and specify a business tier org)
--proxy-http-mode=<mode> HTTP Proxy mode, system (default) or manual
--override-proxy-http=<URL> URL of the HTTP proxy that must be used for outgoing HTTP requests
--override-proxy-https=<URL> URL of the HTTP proxy that must be used for outgoing HTTPS requests
--override-proxy-exclude=<hosts/domains> Bypass proxy settings for these hosts & domains, comma-separated list
--proxy-enable-kerberosntlm Enables Kerberos/NTLM proxy authentication
\quad\quad 留心以下几行:
--installation-dir=<path> Changes the default installation location (C:\Program Files\Docker\Docker)
--hyper-v-default-data-root=<path> Changes the default hyper-v VM disk location
--windows-containers-default-data-root=<path> Changes the default windows containers data root
--wsl-default-data-root=<path> Changes the default wsl data location
\quad\quad 因此我们可以采用以下的命令安装:
"Docker Desktop Installer.exe" install ^
--quiet ^
--accept-license ^
--backend=wsl-2 ^
--installation-dir=<the installation location where you want> ^
--wsl-default-data-root=<the wsl data location path>