Windows Docker Desktop自定义安装路径

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>
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值