Mounting Win10 directory that has spaces and dashes in the path into Ubuntu Docker Container

Viewed 497

I am trying to mount a Windows 10 directory into an Ubuntu container on docker. The path has spaces and a dash in the name:

C:\Users\eko\OneDrive - MyCo, Inc\_Git\covid19-maps

When I run the following in PowerShell:

docker run -i -v C:/Users/eko/OneDrive\ -\ MyCo,\ Inc/_Git/covid19:/home/covid19 ubuntu:latest

Docker fails with unknown shorthand flag: '\\' in -\

I also tried escaping the dash with a backslash like so /OneDrive\ \-\ MyCo,\ Inc/_Git but that also fails.

2 Answers

Ok - not exactly an answer to the question, but having the git repo in OneDrive was redundant.

I moved it to a less problematic path and it worked.

docker run -i -v C:/_git/covid19:/home/git/covid19 ubuntu:latest

had a very similar problem with docker-compose, using the volumes: section to mount a CIFS share from a windows server, complete with windowsey paths and odd characters.

  • /mnt/public/DRAWING\ LIBRARY/PRODUCT/1.\ New\ Number\ System\ (1\ million,\ T\ Camera,\ Suppliers\ &\ Pack\ Lists)/:/host/documents/drawimgs-million-numbers

This looked fine in VSC, no problems reported, but when I ran docker-compose up, I got very weird errors:

Creating e3-ui      ... error

kdir /mnt/public/DRAWING\ LIBRARY: invalid argument

ERROR: for viewer-app  Cannot start service viewer-app: error while creating mount source path '/mnt/public/DRAWING\ LIBRARY/PRODUCT/1.\ New\ Number\ System\ \(1\ million\,\ T\ Camera\,\ Suppliers\ \&\ Pack\ Lists\)': mkdir /mnt/public/DRAWING\ LIBRARY: invalid argument
ERROR: Encountered errors while bringing up the project.

The solution: wrap the entire volume directive in double-quotes

"/mnt/public/DRAWING\ LIBRARY/PRODUCT/1.\ New\ Number\ System\ \(1\ million\,\ T\ Camera\,\ Suppliers\ \&\ Pack\ Lists\)/:/host/documents/drawimgs-million-numbers"

Works like a charm

Related