-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Mount volume doesn't work on Windows 10 using git-bash #673
Comments
Out of curiosity, can I ask where your |
Related (same?) problem: I can confirm the bug here too. |
I use the workaround described by dsebastien in the issue linked in my previous reply with a small modification to avoid changing the calling shell environment. This is what I use as workaround now, in my ~/.bash_profile on Windows 10, Git Bash:
|
Related issue: moby/moby#24029 |
@anderejd This workaround unfortunately doesn't work for me if {
"scripts": {
"start": "docker run -v $(pwd):/docs ...",
}
} and the volume mapping doesn't work. The only way I can make it work is to update the script directly, like so: {
"scripts": {
"start": "MSYS_NO_PATHCONV=1 docker run -v $(pwd):/docs ...",
}
} which is of course ugly for other team members who don't use Git Bash, or are not on Windows at all. |
This is from mingw intercepting your shell commands and replacing things it thinks are linux filesystem paths with their equivalent windows path. In git-bash you'll need to use double backslashes instead of single in Windows paths. To stop the container path /data getting mangled into C:\\data, you need to use a double-slash rather than just a single at the start.
|
Some more info: my script contains `pwd`, like this:
This resolves to something like:
which does not work. This works:
And this works as well:
So if I want to stay away from hardcoded path value and use `pwd` in some script, I really seem to need to have:
which is unpleasant until you know what you're dealing with. |
@borekb I'm actually not using the workaround I posted any longer. The only sane way seems to be to set |
I tried that but the situation was generally worse (many other things on my system stopped working with permanent I still think that Docker for Windows should support paths like |
UPDATE: I'll keep the info updated in a Gist, I needed that myself a couple of times already during this week. For anyone interested, I now use a workaround that does not depend on a Bash alias but instead puts a script to a PATH. It's the only way I found to make docker and docker-compose happy in Git Bash without needing to manually specify I created two small shell scripts, This is the contents of my #!/bin/bash
(export MSYS_NO_PATHCONV=1; "docker.exe" "$@") Similarly for |
If anyone is curious, I spent some time digging into why this is happening and came up with this. The error is stemming from a POSIX -> Windows API path conversion. Some solutions: |
For Git Bash for Windows (in ConEmu), the following works for me:
Note the backticks/backquotes around With all other variations of PWD I've tried I've received: |
In Git bash (Git for Windows ) add a slash |
Hopefully, people scroll all the way down to @ice7mayu comment, this is the only one that works!
Don't waste your time on all the other comments. |
Only solved when Shared Folder |
I think I started hitting a roadblock with Windows C:\test>docker run -it -v example-root:/root busybox
/ # exit
user@computer MINGW64 /c/test
$ docker run -it -v example-root:/root busybox
the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'
user@computer MINGW64 /c/test
$ winpty docker run -it -v example-root:/root busybox
C:/Program Files/Docker Toolbox/docker.exe: Error response from daemon: create example-root;C: "example-root;C" includes invalid characters for a local volume name, only "[a-zA-Z0-9][a-zA-Z0-9_.-]" are allowed. If you intended to pass a host directory, use absolute path.
See 'C:/Program Files/Docker Toolbox/docker.exe run --help'. The reason I don't just use Anyone have any clue how to workaround that named mount issue? |
I got the same result just like @patricknelson , looks like the above methods don't work now, I'm running Docker Desktop 19.03.5 on Windows 10 1903.
|
@PeterDaveHello this is a limitation of Git for Windows, see https://stackoverflow.com/q/48427366/1195832 |
For me, this kind of syntax currently works on windows 10 1909 and docker desktop 19.03.5:
|
@PeterDaveHello were you able to find a solution that does not involve pre-pending a POSIX paths with an additional E.g not this:
Edit: I finally found a solution, it was to roll back to an appropriate version of Git for Windows. The latest, as of today v2.27.0, does not seem to recognize the |
So the only solution now is adding MSYS_NO_PATHCONV=1? |
Best solution is to prefix absolute paths with "//" when running bash on windows. A path that starts with "/[a-z]/" is transformed into a drive number, and other paths, even those that start with a single "/", are treated as relative paths. Using "//" is the POSIX way to say "this is an absolute path". |
It seems to be doing something weird with the path.
On git-bash:
On cmd.exe:
The text was updated successfully, but these errors were encountered: