Move Docker for Windows Hyper-V Disk VHDX to another drive

28/03/2018

Been using Docker for Windows quite a lot lately.

Unfortunately running docker containers on windows is still not done natively, so we have to rely on a Linux Hyper-V Virtual Machine. This VM have a tendency to grow large quite fast if you work with many images, and yesterday I found myself running out of space on my C-drive due to that.

Luckily I thought I could just change the settings for the vhd location from the docker for windows settings to my other drive. But nope. That didn’t work. Then I tried to move the Hyper-V disk manually, and changing the path in Hyper-V, which just resulted in Docker for windows reprovisioning the Hyper-V machine to the C-drive again.

In the end, it turns out that this functionality is quite buggy, so the way I managed to move my disk was to close docker completely. And move the disk to my other drive E:\VirtualMachine\MobyLinuxVM.vhdx. When that is done you can edit
C:\Users\blasi\AppData\Roaming\Docker\settings.json and change the value of MobyVhdPathOverride to the new location of the VHDX E:\\VirtualMachine\\MobyLinuxVM.vhdx. When you restart the docker for windows service, it will pick up the change and change your Hyper-V configuration for you.