for-win icon indicating copy to clipboard operation
for-win copied to clipboard

Move MobyLinuxVM.vhdx to another drive

Open eliassal opened this issue 8 years ago • 33 comments

Expected behavior

In settings, it gives the impression that we can change the location of MobyLinux.vhdx , Docker for windows refuse to change "MobyLinux.vhdx" location

Actual behavior

I clicked on settings > Advanced, changed to a new directory on a another drive, clicked apply, Docker for windows revert back to

C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx

Information

  • Yes reproducible
  • page URL if this is a docs issue or the name of a man page
  • Windows 10 Enterprise

Steps to reproduce the behavior

1.Right Click the whale, chose advanced 2.browse to another directory, for example E:\docker 3.Hit apply 4. Docker for windows revert back to the 1st directory and starts

eliassal avatar Jan 20 '18 21:01 eliassal

try moving it from hyper v, although i can move it from inside docker.

win 10 1709, Docker version 17.12.0-ce, build c97c6d6

hyper v shows this if i move disk from docker hv

ChaerilM avatar Jan 22 '18 04:01 ChaerilM

I managed to do it from inside docker also, thanks

eliassal avatar Jan 22 '18 23:01 eliassal

Zabanya, since I did the change, whenever I try toi switch to linux containers mode, it crashes with the following message Crash ID is

54E91A22-1B28-4D5A-9325-27354CD3129B/2018-01-23_04-19-12

I looked at thread #271 but nothing useful

Docker hv-sock proxy (vsudd) is not reachable at Docker.Backend.ContainerEngine.Linux.ConnectToVsud(TaskCompletionSource`1 vmId) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:line 293 at Docker.Backend.ContainerEngine.Linux.DoStart(Settings settings, String daemonOptions) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:line 260 at Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Backend\ContainerEngine\Linux.cs:line 130 at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass9_0.b__0(Object[] parameters) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Core\pipe\NamedPipeServer.cs:line 47 at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters) in C:\gopath\src\github.com\docker\pinata\win\src\Docker.Core\pipe\NamedPipeServer.cs:line 145

eliassal avatar Jan 23 '18 12:01 eliassal

Here is the log file as well DockerCrashlog.txt

eliassal avatar Jan 23 '18 12:01 eliassal

For what it's worth, I'm getting this same issue. It seemed like perhaps running the daemon as administrator might work, or removing Read-Only from the Hyper-V or Virtual Hard Disks directories, but neither changes the error message, and that directory reverts back to read-only immediately, even with admin privileges.

rtbs-dev avatar Feb 14 '18 14:02 rtbs-dev

I also needed to move my VHD to my other drive (My C: drive is a small SSD, my E: drive is a big HDD)

The settings menu did not work, but I found a workaround.

  1. Shut down Docker
  2. Move the C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx to E:\Foo\Bar\MobyLinuxVM.vhdx
  3. Edit %APPDATA%\Docker\settings.json to set "MobyVhdPathOverride": "E:\\Foo\\Bar\\MobyLinuxVM.vhdx"
  4. Start Docker

So the setting works, but just not through the settings menu for some reason. ¯_( ツ )_/¯

I hope this works for you too

nategraf avatar Mar 15 '18 16:03 nategraf

I just tried this, and it seemed to work fine through the Docker for Windows UI. Docker restarted, and (since I had the HyperV Manager open) the HyperV Manager showed 'Moving storage' and moved the VHDX into the new path.

The settings.json file was also updated.

After restarting the daemon, the text box in the settings UI (which was locked for interaction) reverted to the old location, but once HyperV was finished moving the storage, it updated to the new location.

TBBle avatar Apr 29 '18 11:04 TBBle

Thanks for testing. Looks like this is fixed. Closing

rn avatar Apr 29 '18 17:04 rn

Shouldn't have closed this off so soon, and should have tested 'solution' better - using move in Hyper-V manager moves file systems to new location but does not update kitematic. Kitematic has no easy way of seeing the new location as far as I can tell. There is huge confusion as to where Linux containers are stored, where windows containers are stored, where overlays are stored, where configuration files are stored, and there are no examples in the configuration file (settings.json) of valid file paths, the examples above just use very simple paths. To state clearly: the process of moving docker containers, images, configuration files from one location to another is both valid, needed and extremely poorly documented, leading to a great deal of confusion and wasted effort, and really angering a lot of people who are are trying to assess docker containerisation as a valid solution to the devops problem. I am trying to use docker as a means of getting on with a job without worrying about configuration and reproducibility issues and it just frustrates every reasonable request put on it. One of the major issues is that files are just sprayed all over file systems with apparent scant regard for isolation, ditto for paths and environment variables. Just a mess! What ever happened to just relatively rooted folders and paths, with one location as a starter, and simple locations for executables and config files. Where is kitematic located anyway? Where do you config it? Googling just vomits irrelevant crap spewing from the keyboards of "mvp's" who just need the output to maintain status...

walkerjian avatar Jun 26 '18 06:06 walkerjian

@walkerjian I suspect that by doing the move in Hyper-V Manager rather than the Docker for Windows UI, you have suffered a different issue.

Also, if you're dealing with Windows containers and Linux containers at the same time, then you're using an experimental mode, and are possibly suffering issues from that too.

When I tested this feature, I was using the Linux container mode. I'm not sure if MobyLinuxVM.vhdx is used for Linux containers in Windows container mode (i.e. "LCOW") or not. I suspect not, since when in Windows container mode, the Linux containers previously pulled are not visible to Docker, and become visible again when switching to Windows container mode.

TBBle avatar Jul 11 '18 23:07 TBBle

I am having the same issue. Docker is in the Linux container mode. Steps to reproduce the behavior:

  1. right click the whale and exit
  2. move "MobyLinuxVM" from "Hyper V Manager", "Choose Move Type" -> "Move the virtual machine's storage", "Choose Move Option" -> "Move all of the virtual machine's data to a single location", than choose a folder in another drive like "D:\docker-storage"
  3. restart docker In Docker's settings -> Advanced, "Disk Image Location" is still the old one:
C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\MobyLinuxVM.vhdx

Enter the path above, a new MobyLinuxVM.vhdx is created. And value of "MobyVhdPathOverride" in settings.json is null. Following @nategraf 's solution solved my problem.

fengyuentau avatar Aug 22 '18 11:08 fengyuentau

@fengyuentau That's correct, if you do the move from Hyper-V Manager (rather than the Docker for Windows UI), then Docker needs to have its configuration updated to the new location. There don't appear to be any problem reports left in this ticket that don't relate to moving the image in Hyper-V Manager.

Perhaps someone needs to open a feature request for Docker for Windows to detect/handle that, since it's clearly a desired use-case.

TBBle avatar Aug 30 '18 00:08 TBBle

This worked for me on Windows 10 PRO, Docker 18.9

  1. Uninstall Docker
  2. Change the default Virtual machine and Virtual hard Disk locations in the Hyper-V settings (not on the VM settings)
  3. Install Docker

james-poulose avatar Dec 26 '18 04:12 james-poulose

I tested this again last week (against 18.09) and it still works to change the location in the Docker 'Advanced Settings' page as described in the original problem report.

If you're doing things in Hyper-V manager, then you're making it harder for yourself, because Docker for Windows is trying to manage that Hyper-V machine for you.

Changing the default folder for Virtual Hard Disk locations in Hyper-V host-machine settings is generally a good idea, the default location is... odd. But you don't need to uninstall Docker to move the image its already created.

TBBle avatar Dec 27 '18 06:12 TBBle

My workaround using the directory junction feature - no need to reinstall Docker or change Hyper-V settings:

  1. Quit Docker so as to be able to manipulate with the virtual disk file 1.1 For safety back up your MobyLinuxVM.vhdx file to some different location
  2. Create a folder on the other disk, for example D:\docker-disk
  3. Move MobyLinuxVM.vhdx into this folder
  4. Open cmd (not powershell) as Administrator
  5. Create the dir junction with the command: mklink /J "c:\Users\Public\Documents\Hyper-V\Virtual hard disks" "D:\docker-disk"
  6. Start Docker

airyboy avatar Jan 14 '19 14:01 airyboy

Just tried it today (against 2.0.0.2) it does not move the location using either method. Always reverts to default after restart. Windows 10 17134.

powertoaster avatar Jan 22 '19 15:01 powertoaster

For what it's worth, I had to change the default location under "Hyper-V" settings as well as move the VM files through Hyper-V manager. Then, starting docker and keeping the new location worked.

codymullins avatar Jan 25 '19 14:01 codymullins

codymullins, I had to do the exact same thing. Which means that this bug was closed too soon, and still very much exists.

powertoaster avatar Jan 26 '19 16:01 powertoaster

@powertoaster To be clear, when it reverted to default after restart, was that restart of the daemon? And did you actually wait for the moving process to complete in Hyper-V? The Docker UI will revert to showing the old location because Hyper-V is doing a move underneath, and will update the details when it completes.

I've just re-retested it with 2.0.0.2:

  • With "Docker is running" shown
  1. Create a folder, "D:\Hyper-V Disk Images 2"
  2. Go to Settings -> Advanced
  • Note existing Disk image location: "D:\Hyper-V Disk Images\MobyLinuxVM.vhdx"
  1. Click Browse
  2. Select "D:\Hyper-V Disk Images 2"
  • Note Disk image location updated: "C:\Users\paulh\Hyper-V TM\MobyLinuxVM.vhdx"
  1. Click Apply
  • Status changes to "Docker is starting..."
  1. Wait for Docker restart to complete
  2. State changes to "Docker is running"
  3. Disk image location will switch back to "D:\Hyper-V Disk Images\MobyLinuxVM.vhdx" while the move is taking place.
  • If the image-move completes quickly enough, you may not see this. I had to move four times across drives before I managed to see this stage in Docker Settings.
  • You can instead watch Hyper-V Manager, which will show a Status of "Moving Storage" after it reaches State "Running", as Hyper-V is the one actually moving the image, not Docker Settings.
  1. Disk movement completes in Hyper-V, and the Disk image location in Docker Settings updates again to "C:\Users\paulh\Hyper-V TM\MobyLinuxVM.vhdx"

I suspect if you stop Docker while it's moving the storage, it tells Hyper-V to abort the move. Is that perhaps what you're doing, at step 8, when you see the location switch back to the old location?

If not, to diagnose the failure, follow the above steps, and where it goes wrong:

  • Have Hyper-V Manager open, and the MobyLinuxVM selected when you perform the move from withing Docker Desktop. Keep the "Docker Settings" window open the whole time too, so you can see both.
  • Follow the above steps, and work out where it stops matching the above steps.
  • Try and note what's happening in Hyper-V Manager's "State" and "Status" columns for the MobyLinuxVM, and what's happening in the Docker Desktop settings window.

It might help to record your screen if possible, so you can review what was going on without needing to see the precise moment on the first try.

TBBle avatar Jan 29 '19 13:01 TBBle

@fengyuentau @eliassal @powertoaster @rn - I think we should reopen this issue. Or at the very least, we should have better documentation about expected behavior and caveats, in the Docker settings UI.

I am facing this on Version 2.0.0.3 (31259).

Another thing I am noticing is that %APPDATA%\Docker\settings.json does not have the field ""MobyVhdPathOverride" at all, for it to be changed to a new directory. Adding that field to the json file has no impact, and on docker restart, in the settings UI, we can see that change of directory isn't reflected.

Would appreciate if someone has a workaround that actually works.

arvind-subramanian avatar Apr 05 '19 12:04 arvind-subramanian