docker / for-win

Bug reports for Docker Desktop for Windows
https://www.docker.com/products/docker#/windows
1.87k stars 291 forks source link

Disk image location is not changing #13345

Open vault-thirteen opened 1 year ago

vault-thirteen commented 1 year ago

Actual behavior

Docker Desktop v4.17.1 Settings -> Resources -> Advanced: Disk image location is set to

C:\Users\username\AppData\Local\Docker\wsl

I press the "Browse" button and select a new location. The text under the "Disk image location" label changes to:

J:\WSL\VM\DockerDesktop\DockerDesktopWSL

I press the "Apply & restart" button and wait. An empty folder named 'DockerDesktopWSL' is created and that's all. Disk image is not in that folder.

I restart the Docker Desktop program. Go to the same settings again and what I see is: the 'Disk image location' is set to the old path before the change !

C:\Users\username\AppData\Local\Docker\wsl

Expected behavior

I expect the disk images to be moved to a new location specified in the settings.

Information

Is it reproducible? I hope so.

Is the problem new? I did not use Docker Desktop before.

Did the problem appear with an update? No.

Windows Version: Microsoft Windows [Version 10.0.19045.2728]

Docker Desktop Version: v4.17.1

WSL2 or Hyper-V backend? WSL2

Are you running inside a virtualized Windows e.g. on a cloud server or a VM: No. Real Windows.

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

C:\Program Files\Docker\Docker\resources>"C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check [2023-03-28T19:49:31.882953400Z][com.docker.diagnose.exe][I] set path configuration to OnHost Starting diagnostics

[PASS] DD0027: is there available disk space on the host? [PASS] DD0028: is there available VM disk space? [PASS] DD0002: does the bootloader have virtualization enabled? [SKIP] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0022: is the Virtual Machine Platform Windows Feature enabled? [PASS] DD0021: is the WSL 2 Windows Feature enabled? [PASS] DD0024: is WSL installed? [PASS] DD0025: are WSL distros installed? [PASS] DD0026: is the WSL LxssManager service running? [FAIL] DD0029: is the WSL 2 Linux filesystem corrupt? [ 4.961706] EXT4-fs error (device sdc): ext4_put_super:1188: comm Xwayland: Couldn't clean up the journal [PASS] DD0035: is the VM time synchronized? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0013: is the $PATH ok? [PASS] DD0003: is the Docker CLI working? [PASS] DD0005: is the user in the docker-users group? [PASS] DD0038: is the connection to Docker working? [PASS] DD0014: are the backend processes running? [PASS] DD0007: is the backend responding? [PASS] DD0008: is the native API responding? [PASS] DD0009: is the vpnkit API responding? [PASS] DD0010: is the Docker API proxy responding? [PASS] DD0006: is the Docker Desktop Service responding? [SKIP] DD0030: is the image access management authorized? [PASS] DD0033: does the host have Internet access? [PASS] DD0002: does the bootloader have virtualization enabled? [PASS] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0022: is the Virtual Machine Platform Windows Feature enabled? [PASS] DD0021: is the WSL 2 Windows Feature enabled? [PASS] DD0024: is WSL installed? [PASS] DD0025: are WSL distros installed? [PASS] DD0026: is the WSL LxssManager service running? [WARN] DD0029: is the WSL 2 Linux filesystem corrupt? [ 4.961706] EXT4-fs error (device sdc): ext4_put_super:1188: comm Xwayland: Couldn't clean up the journal [PASS] DD0035: is the VM time synchronized? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0032: do Docker networks overlap with host IPs?

Please note the following 1 warning:

1 : The check: is the WSL 2 Linux filesystem corrupt? Produced the following warning: [ 4.961706] EXT4-fs error (device sdc): ext4_put_super:1188: comm Xwayland: Couldn't clean up the journal

If the WSL 2 Linux filesystem is corrupt then Docker Desktop cannot start. There is a known issue fixed in Windows Insider builds which can cause filesystem corruption, see: https://github.com/microsoft/WSL/issues/5895 .

Try running "wsl --shutdown" to stop your WSL Virtual Machine. When it restarts it will run a filesystem check and hopefully fix the problem.

Please investigate the following 1 issue:

1 : The test: is the WSL 2 Linux filesystem corrupt? Failed with: [ 4.961706] EXT4-fs error (device sdc): ext4_put_super:1188: comm Xwayland: Couldn't clean up the journal

If the WSL 2 Linux filesystem is corrupt then Docker Desktop cannot start. There is a known issue fixed in Windows Insider builds which can cause filesystem corruption, see: https://github.com/microsoft/WSL/issues/5895 .

Try running "wsl --shutdown" to stop your WSL Virtual Machine. When it restarts it will run a filesystem check and hopefully fix the problem.

Steps to reproduce the behavior

See above.

vault-thirteen commented 1 year ago

I have tried the suggestion of the com.docker.diagnose.exe utility. I have shut the WSL down, rebooted the PC, but nothing has changed.

wsl --shutdown

The diagnostics is the same.

vault-thirteen commented 1 year ago

I mentioned this issue in the WSL issue tracker. https://github.com/microsoft/WSL/issues/5895

ArtificialTruth commented 1 year ago

I can reproduce this issue. Eg trying to change the "Disk image location" from SSD to HDD by moving from C: drive to : B:\user\AppData\Local\Docker\wsl\DockerDesktopWSL

Will just create the folder, and docker desktop will just show the loading icon, with no disk activity on B: drive. Clicking cancel will show Docker engine is not running I just ran the docker debug: https://pastebin.com/bdvFK839

graceyudhaaa commented 1 year ago

i experience the same problem, the loading icon keeps spinning forever and the docker engine is stopped. trying to restart it and the changes are not applied.

from another issue for the mac version. i found a workaround by downgrading the docker desktop version 4.17 stopped the loading phase. but the disk image location reverts back to C: drive

hotenov commented 1 year ago

Yesterday I ran into this issue with latest stable Docker Desktop 4.19.0 (106363) and today I ended up with workaround.

UPD1: for 4.20.0

Still does NOT work, but developers have fixed "something" in related issue #13269 So, new issue was created #13522 (wait again until next "fix" πŸ˜₯)

Temporary solution

Manually change setting customWslDistroDir in %APPDATA%\Docker\settings.json

2023-05-17_19-32-54

BUT there are several caveats, please read and repeat carefully πŸ€“

How to implement this workaround

Step 0

First of all, after installing Docker Desktop I installed Debian WSL distribution and set it as default distro (before that the default distro was docker-desktop-data). I don't think this is a critical moment, but Microsoft Learn (former docs) website recommends to install WSL distro before installing Docker Desktop. So, if you need exact PowerShell commands for that:

Install WSL2 Linux distribution and set it as default distro (click to expand) ```pwsh # I chose 'Debian' but you can install another. Run 'wsl --list --online' to see available distributions # Somewhere (I don't remember) username and password will be required from you (for the first distro user) wsl --install Debian wsl --setdefault Debian # To see all installed distribution, where * marks default distro wsl --list --verbose # Maybe unnecessary step, but it ensures us that default distro will run wsl ~ # Exit from bash shell (logout) exit ```

However, you can try without installing (changing) default WSL distribution. Maybe it will work with docker-desktop-data as default. Then, give us feedback, because I didn't test it 😏

Step 1

If you are lucky, one of two ext4.vhdx files (the smallest one) will be moved from old location %LOCALAPPDATA%\Docker\wsl\distro\ext4.vhdx to specified (new) location D:\apps\Docker\docker_wsl_images\wsl\main\ext4.vhdx

Pay attention that sub folder is changed (in my case) from "distro" to "main".

If you are not so lucky (like me), click again... Docker Desktop may run with custom WSL image path, but "hang up" on stage "Starting the Docker Engine…" or you might see "Unexpected WSL error" message with error "A timeout occurred while waiting for a WSL integration agent to become ready". In my case, I had to shutdown Docker process manually in Task Manager. Then I did `wsl --shutdown` and run the default Debian distro `wsl ~` before running Docker Desktop.

Step 2

Unfortunately, the largest ext4.vhdx (~1.44GB) file for docker-desktop-data distro stays in its [default] place: %LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx

But you can move it manually. I found a way to do that in this comment.

If you're lazy, I'll provide commands for my paths (click to expand) ```powershell wsl --shutdown wsl --export docker-desktop-data "D:\_cache\2023-05-17_19-41 backup docker-desktop-data distro\docker-desktop-data.tar" # ATTENTION: The following command deletes .vhdx file (~1.44GB) in '%LOCALAPPDATA%\Docker\wsl\data\ext4.vhdx' # DO BACK UP BEFORE YOU LOST YOUR DATA 😐 wsl --unregister docker-desktop-data wsl --import docker-desktop-data "D:\apps\Docker\docker_wsl_images\wsl\data-distro" "D:\_cache\2023-05-17_19-41 backup docker-desktop-data distro\docker-desktop-data.tar" --version 2 ```
Screenshot of these commands in my PowerShell (click to see the picture) ![2023-05-17_20-01-22](https://github.com/docker/for-win/assets/11818507/ab450473-c09e-448c-9a89-2854123930eb)

After moving the image file, Docker Desktop should run normally.
I hope this long long comment will help someone πŸ˜‰

My environment (WSL and Docker versions) ... ```bash PS> wsl --version WSL version: 1.2.5.0 Kernel version: 5.15.90.1 WSLg version: 1.0.51 MSRDC version: 1.2.3770 PS> docker --version Docker version 23.0.5, build bc4487a ```
TheOdemMove commented 1 year ago

yes, such a problem really exists (the recommendations above really helped to solve the problem) I don't quite understand why it is not possible to choose the drive on which docker desktop will be installed during installation.

hotenov commented 1 year ago

I don't quite understand why it is not possible to choose the drive on which docker desktop will be installed during installation.

@TheOdemMove Hi! Actually, it's possible 😎 You can't specify where to install Docker's VM (docker-desktop-data and docker-desktop) in installation wizard, BUT you can choose where to install Docker Desktop app (and all its components, ~2.8 GB on Windows). However, you have to install Docker Desktop from the command line in this case. The option --installation-dir will help you πŸ˜‰

Docker documentation provides the example without additional command-line arguments. Here's the example for PowerShell to install Docker Desktop to the custom folder:

Start-Process "D:\Docker Desktop Installer.exe" -Wait -ArgumentList "install --installation-dir=D:\apps\Docker\Docker"

Note: Pay attention that there is no any quotes for path value. I didn't try the path with spaces but you can pass a list of strings to -ArgumentList which are not split (as when we pass a single string, my example). See more about ArgumentList

flyween commented 1 year ago

I can reproduce this issue. Eg trying to change the "Disk image location" from SSD to HDD by moving from C: drive to : B:\user\AppData\Local\Docker\wsl\DockerDesktopWSL

Will just create the folder, and docker desktop will just show the loading icon, with no disk activity on B: drive. Clicking cancel will show Docker engine is not running I just ran the docker debug: https://pastebin.com/bdvFK839

Same with me

zhqu1148980644 commented 1 year ago

Facing the same issue with hyper-v in the current latest windows docker desktop

try this solution:

  1. quit docker desktop
  2. edit %APPDATA%\Docker\settings.json, change the location to what ever you want
  3. start docker desktop
pjd79 commented 10 months ago

Same problem on linux debian 12 with docker desktop v4.27.0 when moving Disk image location from an SDD to an HDD. I fix that by editing the dataFolder field in $HOME/.docker/desktop/settings.json. Thanks to these messages for helping me to fix this.

sonicviz commented 9 months ago

Confirm the same issue occurs with win 11 and latest Docker desktop.

Solution was https://github.com/docker/for-win/issues/13345#issuecomment-1727929905 except the location to change is in "C:\Users[USER]\AppData\Roaming\Docker\settings.json"

hotenov commented 9 months ago

Confirm the same issue occurs with win 11 and latest Docker desktop.

Solution was #13345 (comment) except the location to change is in "C:\Users[USER]\AppData\Roaming\Docker\settings.json"

@sonicviz Well, I have no Windows 11, but I don't think they changed a behavior for environment variable APPDATA. It lets you 'hide' your real user name in such public instructions.
Try to paste %APPDATA%\Docker in Windows Explorer's address bar and press Enter (see picture below for Windows 10). If you have not changed the default value it evaluated as C:\Users\yourusername\AppData\Roaming\Docker

image

sonicviz commented 9 months ago

Sure, I just prefer seeing complete paths rather than virtual. Either way is fine if it resolves to where you need to get to. The bigger issue is Docker Desktop is still bugged trying to do this in the app. Not a big deal to edit the settings manually, but would be nice if it wasn't bugged as well!

hyysguyang commented 9 months ago

Facing the same issue with hyper-v in the current latest windows docker desktop

try this solution:

  1. quit docker desktop
  2. edit %APPDATA%\Docker\settings.json, change the location to what ever you want
  3. start docker desktop

This is OK, fixed it with this solution, thanks.

Manthazar commented 1 month ago

@zhqu1148980644 Does not work for me. After changing the path in the file, Docker Desktop 4.34.3 confirms the directory. Puts something into it, but NOT the images. They are still stored somewhere. Notably the images screen also does not help to show them.

Fun fact: if you wanted to user Portainer/Portainer to inspect settings, Docker Desktop again lets you down with 404, access denied. You have read correctly. 404, access denied....

CreateSean commented 6 days ago

@zhqu1148980644 Does not work for me. After changing the path in the file, Docker Desktop 4.34.3 confirms the directory. Puts something into it, but NOT the images. They are still stored somewhere. Notably the images screen also does not help to show them.

I also had this issue today.

MortInfinite commented 12 hours ago

I experience the same problem with version 4.36.

The previously mentioned %APPDATA%\Docker\settings.json does not exist.

Using the previously mentioned docker installation arguments --installation-dir=D:\apps\Docker\Docker changes where docker is installed, but does not change where docker saves its disk images.

The error message I get is: An error occurred while applying the "Disk image location" setting. The previous value has been restored.

status not OK but 500: Unhandled exception: Source and destination directory owner mismatch.

Manually setting the same folder owner on the old and the new directory, does not change anything. Manually moving the DockerDesktop folder to the new location doesn't work, as Docker requires the folder to not already exist.