How to install Docker Desktop on a different drive (location) on Windows
Asked Answered
D

11

39

I've had Docker Desktop installed on my C:\ drive for a while now and it keeps hogging space on my SSD. Even if I delete all of my containers and images it still takes a lot of space, I'm guessing some cached files or something. The only way I could recover space on my SSD is to fully uninstall Docker Desktop.

I've been trying to install Docker Desktop onto a larger HDD but it's not an option on the installer. I've seen some guides about modifying the services and supplying the --data-root flag but it doesn't seem to work. I couldn't restart the dockerd service, etc.

Despumate answered 13/3, 2023 at 21:30 Comment(2)
forums.docker.com/t/… HTH Did not test it yetScoria
The commends has changed. Refer this link github.com/docker/docs/issues/18264Alphosis
S
77
  • Don't install using double click on "Docker Desktop Installer.exe".
  • Open windows terminal as Administrator.(Right click on the Terminal icon and click on Run as administrator).
  • Goto the folder where "Docker Desktop Installer.exe" downloaded. And run start /w "" "Docker Desktop Installer.exe" install -accept-license --installation-dir=E:\path\to\folder

Note: the WSL, image etc still will be in %HOME%\AppData\Local\Docker. As noted in comments, you can change that too by adding: --wsl-default-data-root=E:\path\to\data\folder
(for Windows 11, you might also check the another answer in this thread)

Documentation: https://docs.docker.com/desktop/install/windows-install/#install-from-the-command-line

Sidneysidoma answered 5/5, 2023 at 11:43 Comment(5)
This answer is the correct approach. And if you want to also store images in another drive instead of the default location, you need to pass an additional flag --wsl-default-data-root=E:\Path\to\Data\Folder.Oldie
Notice: No trailing slashes when providing the paths to installation-dir or default-data-root argument. Also, here's the command to install and also store images to your desired drive: start /w "" "Docker Desktop Installer.exe" install -accept-license --installation-dir=D:\Docker --wsl-default-data-root=D:\Docker\imagesKaon
I had this error: "Unexpected token 'install' in expression or statement". For solving, I wrote '.\Docker Desktop Installer.exe' and the rest of the commands. Simple quotes and problem solved!Piecrust
also there is option in GUI: https://mcmap.net/q/209921/-change-docker-native-images-location-on-windows-10-proStylograph
It works fine, thanksAquavit
S
20

I've tried many methods as suggested and it did install as expected to different drive than C when using command line. The problem was that it worked with linux containers and images but was still saving Windows images and containers in default C ProgramData although I inserted --windows-containers-default-data-root="D:\Docker" when installing.

This is what worked for me to install and save images and containers under D drive.

  • after download of "Docker Desktop Installer.exe" file
  • open the windows terminal as administrator and go to where you downloaded the file
  • run the following command

start /w "" "Docker Desktop Installer.exe" install -accept-license --installation-dir="D:\Docker\Docker" --wsl-default-data-root="D:\Docker\wsl" --windows-containers-default-data-root="D:\\Docker"

Turns out the flag --windows-containers-default-data-root="D:\\Docker" needed two backslashes instead of one.

Samualsamuel answered 26/8, 2023 at 8:56 Comment(3)
Using Windows 11, this saved the dayKessia
works with WSL2 Windows containers on Windows 10 and 11, with version of Docker: 4.27.2. Confirmed C:\ProgramData\DockerDesktop only contained some logs. Everything else filled up the D:\containers folder I specified.Portly
I think this should be the correct answer.Simms
A
8

In Windows 11 it worked like this:

Start-Process -Wait -FilePath "Docker Desktop Installer.exe" -ArgumentList "install", "-accept-license", "--installation-dir=D:\Docker\Docker", "--wsl-default-data-root=D:\Docker\wsl", "--windows-containers-default-data-root=D:\\Docker"
Abernethy answered 8/12, 2023 at 7:7 Comment(0)
Y
6
  • Open PowerShell(Run as Administrator).

  • Navigate to that folder where Docker Desktop Installer.exe is located.( cd folderpath ).

  • Run this command Start-Process -Wait -FilePath "Docker Desktop Installer.exe" -ArgumentList "install -accept-license --installation-dir=E:\Docker"

Yasminyasmine answered 30/10, 2023 at 19:41 Comment(0)
S
4

This Worked For me Using CMD(Admin) "D:\UserName\Downloads\Music\Docker Desktop Installer.exe" install -accept-license --installation-dir="E:\Program Files\Docker"enter image description here

Stipend answered 23/8, 2023 at 13:37 Comment(0)
A
1

Start-Process -FilePath "Docker Desktop Installer.exe" -ArgumentList "install -accept-license --installation-dir="D:\Program Files\Docker" --wsl-default-data-root="D:\Docker\wsl" --windows-containers-default-data-root="D:\\Docker"" -Wait

This worked for me, open the powershell where this exe file is located

Automotive answered 14/5, 2024 at 2:34 Comment(0)
K
0

After installation on a different drive on windows 10, you can face an issue with WSL. An error pops up with information related to wsl and recommends running wsl --shutdown command etc. I tried to fix the error but I couldn't.

The only solution I found was to install it again on the main C:\ drive but change the image location to a different drive.

Kaon answered 21/8, 2023 at 1:23 Comment(1)
To change location of images being stored: https://mcmap.net/q/209921/-change-docker-native-images-location-on-windows-10-proKaon
H
0

Windows terminal as administrator - Start-Process -FilePath "G:\APPS\Docker Desktop Installer.exe" -ArgumentList "install", "-accept-license", "--installation-dir=G:\Docker", "--wsl-default-data-root=G:\Docker\images" -Wait

Note: Make sure to create a folder named "Docker" and another folder named "images" inside the Docker folder within your desired volume, in my case it was G:\

Hornet answered 15/11, 2023 at 3:50 Comment(0)
R
0

Similar to Mujeeb I got the error message suggesting wsl --shutdown. What fixed it for me was creating the specified WSL folder from the original Powershell command.

See https://forums.docker.com/t/docker-installation-directory/32773/24

Racehorse answered 12/3, 2024 at 9:22 Comment(0)
L
-1

2Answer Right u must First

  1. cut the docker desktop installer to a random folder in drive e 2.create text document on that folder and paste this ----> /w "" "Docker Desktop Installer.exe" install -accept-license --installation-dir=E:\Docker\Docker
  2. Click on Save as and click on all files and write for example hello.bat 4.now run it
Lepidote answered 22/8, 2023 at 12:41 Comment(2)
Stack Overflow is not a blog, forum or chat site. Rather, it is an encyclopaedia-like repository of information. So, please refrain from using vulgar, SMS-oriented abbreviations like "u" and "2answer", and edit your post to use proper English.Quadrature
Are you the grammer police?Orpington
A
-1

In my case, this worked well

Start-Process -Wait -FilePath "Docker Desktop Installer.exe" -ArgumentList "install", "-accept-license", "--installation-dir=D:\Docker", "--wsl-default-data-root=D:\Docker\images"
Albur answered 10/11, 2023 at 22:6 Comment(1)
Although this code might answer the question, I recommend that you also provide an explanation what your code does and how it solves the problem of the question. Answers with an explanation are usually more helpful and of better quality, and are more likely to attract upvotes.Aikoail

© 2022 - 2025 — McMap. All rights reserved.