Importing Docker Toolbox content fails if path contains whitespace

As a user of Docker Toolbox, I am asked if I want to import the images/containers from my Toolbox default machine during the initial install/setup of Docker for Windows (Hyper-V), or post-install via Settings > Reset > Reset to Toolbox default machine content…

Expected behavior

Docker Toolbox default machine images and containers are migrated to Docker for Windows

Actual behavior

Error occurs immediately (<1 second) after starting the import. No images or containers are migrated.

Information

Error notification says: "Failed to to migrate volume: <path to default/disk.vmdk>"

Relevant log output:

[14:01:50.633][Program        ][Info   ] 1.12.0-rc3-beta18
[14:01:50.633][Program        ][Info   ] Starting on: 7/7/2016 2:01:50 PM
[14:01:50.633][Program        ][Info   ] Resources: C:\Program Files\Docker\Docker\Resources
[14:01:50.633][Program        ][Info   ] OS: Windows 10 Enterprise Insider Preview
[14:01:50.648][Program        ][Info   ] Edition: Enterprise
[14:01:50.648][Program        ][Info   ] Id: 1607
[14:01:50.648][Program        ][Info   ] Build: 14372
[14:01:50.648][Program        ][Info   ] BuildLabName: 14372.0.amd64fre.rs1_release.160620-2342
[14:01:50.648][Program        ][Info   ] Mixpanel Id: 893236F5-8F67-44E2-B1CB-BFEE912D65FD
[14:01:50.664][Program        ][Info   ] Sha1: 5cbabb0783b6d281b8f579cb9f4dff38373b2c10
[14:01:50.664][Program        ][Info   ] You can send feedback, including this log file, at https://forums.docker.com/c/docker-for-windows
[14:01:51.065][TrackingStatus ][Info   ] Crash report and usage statistics are enabled
[14:01:51.096][Mixpanel       ][Info   ] Usage Statistic: appLaunched
[14:01:51.852][NamedPipeClient][Info   ] Sending Version()...
[14:01:51.852][NamedPipeClient][Info   ] Received response for Version
[14:01:51.867][Mixpanel       ][Info   ] Usage Statistic: heartbeat
[14:00:31.415][BackendServer  ][Info   ] Started
[14:01:51.852][NamedPipeServer][Info   ] Version()
[14:01:51.852][NamedPipeServer][Info   ] Version done.
[14:01:57.693][Notifications  ][Info   ] Docker is migrating default machine...
[14:01:57.693][Updater        ][Info   ] Checking for updates on channel Beta...
[14:01:57.708][NamedPipeClient][Info   ] Sending MigrateVolume(C:\Users\David Jessup\.docker\machine\machines\default\disk.vmdk)...
[14:01:57.708][NamedPipeServer][Info   ] MigrateVolume(C:\Users\David Jessup\.docker\machine\machines\default\disk.vmdk)
[14:01:57.857][DockerMachineImport][Info   ]     (0.00/100%)
[14:01:57.857][DockerMachineImport][Info   ] 
[14:01:57.857][DockerMachineImport][Error  ] C:\Program Files\Docker\Docker\Resources\qemu-img\qemu-img.exe: Could not open 'C:\Users\David': Could not open 'C:\Users\David': Invalid argument
[14:01:57.857][DockerMachineImport][Info   ] 
[14:01:57.857][NamedPipeClient][Error  ] Unable to send MigrateVolume: Failed to migrate volume: C:\Users\David Jessup\.docker\machine\machines\default\disk.vmdk
[14:01:57.857][DockerMachineImport][Error  ] 
[14:01:57.876][Notifications  ][Error  ] Failed to migrate volume: C:\Users\David Jessup\.docker\machine\machines\default\disk.vmdk
[14:01:57.857][NamedPipeServer][Error  ] Unable to execute MigrateVolume: Failed to migrate volume: C:\Users\David Jessup\.docker\machine\machines\default\disk.vmdk    at Docker.Backend.DockerMachineImport.MigrateVolume(String inputVolumePath, String outputVolumePath)
   at Docker.Backend.Backend.MigrateVolume(String vmdkPath)
   at Docker.Core.Pipe.NamedPipeServer.<>c__DisplayClass7_0.<Register>b__0(Object[] parameters)
   at Docker.Core.Pipe.NamedPipeServer.RunAction(String action, Object[] parameters)

It looks like the path argument being passed to qemu-img.exe isn’t quoted and the space in the disk.vmdk path is causing it to be treated as multiple arguments instead of just one.

Steps to reproduce the behavior

  1. Create a user whose home directory contains a space (e.g. “John Doe”)
  2. Install Docker Toolbox
  3. Upgrade to Docker for Windows
  4. Attempt to migrate the Docker Toolbox content into Docker for Windows