When trying to share a local drive with my docker containers using Docker for Windows in my Git Bash shell, I kept getting errors about invalid mount specs. Even just following along with the basic example provided in the Docker for Windows dialog for sharing drives fails:
$ docker run –rm -v c:/Users:/data alpine ls /data
docker: Error response from daemon: invalid bind mount spec “c;C:\\Program Files\\Git\\Users;C:\\Program Files\\Git\\data”: invalid mode: \Program Files\Git\data.
This turns out to be an issue with Git Bash (and MSYS in general) attempting to resolve and expand our paths before handing them off to docker. Escaping the forward-slashes with an extra forward-slash resolves this issue:
$ docker run –rm -v c://Users://data alpine ls //data
This is not an issue from within PowerShell or the Command Prompt, so stick with one of those when working with docker or remember to escape your slashes when passing them into the docker command.