Docker Desktop安装在指定盘
Docker默认是安装在C:Program FilesDockerDocker,包括镜像文件也是存放在宝贵的C盘,这会占用大量的C盘空间,这篇文章帮助你把docker安装到指定的硬盘位置,下面以D盘为例。
下载Docker Desktop
下载Docker Desktop安装文件Docker Desktop Installer.exe
Get Started | Docker
假设下载位置为D盘根目录D:
传统方式安装docker是无法设置安装位置的,所以这里命令进行安装,如果电脑上没启用过wsl,docker会一起安装。
命令行(终端)安装
win+R,输入cmd打开命令提示符,输入以下命令,回车执行
#当前目录切换到D盘
cd d:
#用start命令安装Docker
start /w "" "Docker Desktop Installer.exe" install --backend=wsl-2 --installation-dir=D:Program FilesDocker --accept-license
等待显示 Installation succeeded 安装完成。
这里使用了 --installation-dir参数指定了安装位置D:Program FilesDocker ,可以替换为自己喜欢的位置。如果想在安装时将wsl的部署位置也更改,可以使用 --wsl-default-data-root
参数。该命令还可以接受以下参数:
--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 the Windows containers integration. This can improve security. For more information, see Windows containers.
--allowed-org=
: Requires the user to sign in and be part of the specified Docker Hub organization when running the application
--backend=
: Selects the default backend to use for Docker Desktop,hyper-v
,windows
orwsl-2
(default)
--installation-dir=
: Changes the default installation location (C:Program FilesDockerDocker
)
--admin-settings
: Automatically creates anadmin-settings.json
file which is used by admins to control certain Docker Desktop settings on client machines within their organization. For more information, see Settings Management.
It must be used together with the
--allowed-org=
flag.For example:
--allowed-org=
--admin-settings="{'configurationFileVersion': 2, 'enhancedContainerIsolation': {'value': true, 'locked': false}}"
--proxy-http-mode=
: Sets the HTTP Proxy mode,system
(default) ormanual
--override-proxy-http=
: Sets the URL of the HTTP proxy that must be used for outgoing HTTP requests, requires--proxy-http-mode
to bemanual
--override-proxy-https=
: Sets the URL of the HTTP proxy that must be used for outgoing HTTPS requests, requires--proxy-http-mode
to bemanual
--override-proxy-exclude=
: Bypasses proxy settings for the hosts and domains. Uses a comma-separated list.
--proxy-enable-kerberosntlm
: Enables Kerberos and NTLM proxy authentication. If you are enabling this, ensure your proxy server is properly configured for Kerberos/NTLM authentication. Available with Docker Desktop 4.32 and later.
--hyper-v-default-data-root=
: Specifies the default location for the Hyper-V VM disk.
--windows-containers-default-data-root=
: Specifies the default location for the Windows containers.
--wsl-default-data-root=
: Specifies the default location for the WSL distribution disk.
--always-run-service
: After installation completes, startscom.docker.service
and sets the service startup type to Automatic. This circumvents the need for administrator privileges, which are otherwise necessary to startcom.docker.service
.com.docker.service
is required by Windows containers and Hyper-V backend.
Powershell安装
powershell安装使用如下命令,与cmd相比,多了ArgumentList参数
Start-Process 'Docker Desktop Installer.exe' -Wait -ArgumentList 'install', '--backend=wsl-2 --installation-dir=D:Program FilesDocker --accept-license'
修改镜像存放位置
安装完成后打开docker setting->Resources->Advanced,更改Disk image location选项,把默认的镜像存放位置(C:Userszy921AppDataLocalDockerwsl),修改到D盘。
其他系统的安装方式可以查看官方文档Windows | Docker Docs