dokgu
dokgu

Reputation: 6060

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

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.

Upvotes: 63

Views: 55296

Answers (17)

The Droid Guy
The Droid Guy

Reputation: 177

  1. Download the Docker Desktop exe file.

  2. Open Cmd as a Admin and run the below command.

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

Upvotes: 0

anunaki
anunaki

Reputation: 2294

  • 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"). Make sure you're using Windows Terminal and not Powershell, as the commands are formatted differently (see the Documentation).
  • Go to the folder where "Docker Desktop Installer.exe" downloaded. Run start /w "" "Docker Desktop Installer.exe" install -accept-license --installation-dir=E:\path\to\folder Note: the installer does not create the "Docker" dir this way if you don't specify a directory after the driver letter. Make sure to write E:\Docker at minimum

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

Upvotes: 119

algorix
algorix

Reputation: 331

With Docker Desktop v4.34.3 you can use the "Settings" menu inside de app to change the data location:

docker desktop settings window

Upvotes: 1

Sahil Pulikal
Sahil Pulikal

Reputation: 1

In Windows 11, it worked like this:

  1. I had downloaded "Docker Desktop Installer.exe" from Docker website in Downloads folder.

  2. Open PowerShell in Downloads folder by Shift + right click anywhere in empty area then select "Open PowerShell window here".

  3. In PowerShell, copy paste below command and press enter:

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"

After running Docker Desktop, it started running Docker Engine then, I got below error as I already had ubuntu in WSL installed in my system:

WSL integration with distro 'Ubuntu' unexpectedly stopped. Do you want to restart it?

checking distro state for "Ubuntu": Get "http://ipc/check?distro=Ubuntu": context deadline exceeded: unexpected error

Then I ran below 2 commands in Command Prompt to fix the issue.

Note : Try these below commands if you're willing to risk losing the data.

wsl --unregister docker-desktop

wsl --unregister docker-desktop-data

Upvotes: 0

Joy0x1
Joy0x1

Reputation: 21

I tried all of these cmds but none of them works but this one works perfectly in my system :

$dockerPath = "D:\Applications\Docker.exe"
$installArgs = "install --accept-license --installation-dir=""G:\Docker"" --wsl-default-data-root=""G:\WSL"""

Start-Process -FilePath $dockerPath -ArgumentList $installArgs -NoNewWindow -Wait

Upvotes: 0

Sawtooth
Sawtooth

Reputation: 1

For those who have an error Start-Process : Cannot validate argument on parameter 'ArgumentList'. The argument is null or empty., try launch this in cmd:

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

Don't forget to change the paths to your own.

Upvotes: 0

Chirag Modh
Chirag Modh

Reputation: 11

In Windows 11 Follow below steps:

  1. First open Windows Powershell as run as Administrator.

  2. Download Docker Desktop Installer.exe in Your Download folder.

  3. Now in Terminal you are in "C:\Windows\System32" directory.

  4. so please run this command to go Download Directories where we install our Dcoker exe file cd C:\usres{your-username}\Downloads

  5. after that run below command 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"

Upvotes: 1

vamsi puppala
vamsi puppala

Reputation: 11

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

Upvotes: 1

Nemrah
Nemrah

Reputation: 1

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

Upvotes: 0

Ivan Sarachman
Ivan Sarachman

Reputation: 201

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"

Upvotes: 20

Guy Kouakou
Guy Kouakou

Reputation: 381

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.

Upvotes: 27

Imran
Imran

Reputation: 1

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:\

Upvotes: 0

astro62
astro62

Reputation: 59

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"

Upvotes: -1

Ishav
Ishav

Reputation: 116

  • 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"

Upvotes: 6

M.O.Z
M.O.Z

Reputation: 51

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

Upvotes: 5

Hossein Fathi
Hossein Fathi

Reputation: 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

Upvotes: -1

Mujeeb Ishaque
Mujeeb Ishaque

Reputation: 2731

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.

Upvotes: 0

Related Questions