Git Bash on
Windows 10 and want to mount a folder of the host machine into a docker container.
This is not possible as docker claims the directory would not exist:
$> docker run --rm -v c:/Users:/data alpine ls /data ls: C:/Program Files/Git/data: No such file or directory
Using the Powershell
Powershell instead of
Git Bash sems to work.
The Bug only happens only when using
For me this is not helpful as i need bash for development.
Prepend MSYS_NO_PATHCONV=1 to every docker call
It seems this Bug happens because of a double encoding of the windows path. If the path is only encoded once, docker can mount the folder.
$> MSYS_NO_PATHCONV=1 docker run --rm -v c:/Users:/data alpine ls /data ...
Instead of prepend the docker command with 'MSYS_NO_PATHCONV=1' every time, i created two wrapper scripts:
Put the following into C:\PortableApps\commandhelper\docker (without file extension):
#!/bin/bash echo "using wrapper" (export MSYS_NO_PATHCONV=1; "docker.exe" "$@")
Put the following into C:\PortableApps\commandhelper\docker-compose (without file extension):
#!/bin/bash echo "using wrapper" (export MSYS_NO_PATHCONV=1; "docker-compose.exe" "$@")
Now add C:\PortableApps\commandhelper to the PATH Variable with a higher priority then the docker folder itself.
When this setting is active, we can now use docker directly from
Git Bash without mounting problems:
$> docker run --rm -v c:/Users:/data alpine ls /data using wrapper ...