Docker fails to change the Disk image location

I have googled this problem as it seems to come up quite frequently.

I have tried everything under google to troubleshoot this issue but under docker 4.78.0 (the latest) and Windows 11 with WSL2, if I try to change the disk image location it simply comes back with “Failed to apply settings.” I would provide screenshots but there is really no screenshot to capture of value there other than the error message “Failed to apply settings.”

  • I am running docker as administrator and the destination has plenty of free space for the .vhdx files.

To recreate under windows 11.

Settings → Resources → Select Browse and a new location under “Disk Image Location”

The \AppData\Local\Docker\wsl location has two folders under it.

  • disk\docker_data.vhdx,

  • main\ext4.vhdx

  • I notice right away as soon as I start the operation, the main\ext4.vhdx file is removed

  • In my NEW location a DockerDesktopWSL\disk folder is created and populated with a docker_data.vhdx file

  • The hard drive churns for about 5 minutes

  • The next thing I get is the error that it “Failed to apply settings”

  • Lastly the main\ext4.vhdx is suddenly placed back under its original location.

  • The ext4.vhdx never gets created in the new location.

  • The docker_data.vhdx file remains orphaned in the new location.

I’m at my wits end to change the location of these files as they are eating up my cdrive space. I’ve also tried shrinking the vhdx files to no avail. open DiskPart and select your disk (select vdisk file="C:\path\to\disk.vhdx"), then run compact vdisk. 0 space is reclaimed this way. This is frustrating to say the least as these seem like very basic operations.

This used to work. There is an existing issue on GitHub:
Docker hangs on Disk Image Location change to empty folder on external volume · Issue #195 · docker/desktop-feedback · GitHub

Looks like it could be the same issue.

Update: Never mind. I missed that it’s for Mac. You might want to create a new issue for Windows.

You could check if docker desktop logs provides any additional details.

I did see this one and tried various things from it but it was from three years ago (can a 3 year old bug that is this obvious still be around without being fixed?)… A few issues with what I tried from that incident link.

  • The settings.json file no longer exists, at least I can’t find it on my system. There is a settings-store.json file under roaming/docker but I am unsure of the syntax to set the new directory, and the process for doing it so that docker doesn’t get confused. Is that what that file is even used for?
  • I tried the “change the virtual disk size” hack but low and behold I can’t find this setting in current versions of docker desktop.

I’d pull my hair out over this one but I have none left.

You would think it would be easy to find “A” log file that has the output of setting change process and results, but in going through the local\docker\log\host directory of logs and local\docker\log\vm logs nothing stands out. I’m really trying hard here to get “something” to go off of here. The help is much appreciated. Issue creation is restricted onthat link you sent BTW.

Just to “close” this out I found some steps that worked around it. I wasn’t happy about it but it allowed me to change the location of the data files. I first did a clear/purge, then I did a reset to factory defaults. I didn’t want to do that because it essentially wipes everything. Then before putting my containers back, I followed the process outlined in my original message again. It moved the files with no problem at all. It does mean I have to reinstall my container but meh… it frees up my c-drive. We need BIGGER NVME drives LOL.

Since the issue was for macos, and not for Windows, I doubt that any of the suggestion could have actually worked for you. Docker Desktop uses whatever virtualization technology is available on the host OS.

It is a surprise hat changing the disk image location worked with a fresh state, but not a pre-existing one. I would assume that the utility vm is stopped, before the virtual disk is moved. So in theory it should make a difference whether the virtual disk image had pre-existing state or not.

The settings-store.json indeed stores the settings for the Disk image location, but it doesn’t seem the docs actually cover how the keys actually look like:

Update: it is:

"DataFolder": "/path/to/folder"

Note1: the path is just for the directory the virtual disk(s) are stored in, not the full path to a virtual disk.
Note2: If the DataFolder is changed in settings-store.json, the virtual disk(s) won’t be moved automatically.