I've found some interesting weirdness when trying to mount a docker image on windows.
I created a .sh
script that does a mount of the project folder to run our developer environment image. I want one script that every dev can run, regardless of their machine. All it does is runs docker with the current project folder.
#!/usr/bin/env bash
docker run -it --rm -v D:\my\project\folder:/wkDir $IMAGE_TAG yarn dev
Runs okay. Now the plan is to call this script from npm
, so I'd like this to work relative to the current folder. Let's try another version.
docker run -it --rm -v $PWD:/wkDir $IMAGE_TAG yarn dev
Fails with:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from
daemon: Mount denied:
The source path "D:/my/project/folder;C"
doesn't exist and is not known to Docker.
Wat. What's ;C
and where did it come from?
So I do echo $PWD
which gives me /d/my/project/folder
.
Interesting, so $PWD
resolves to the correct path in linux path format, and it seems like docker is trying to translate from that to the correct windows path, except there's this ;C
that appears out of nowhere. And the \
are /
...
What exactly is going on here?
I get the same result in VSCode's terminal git bash and powershell.
Update: I noticed that running the .sh
in VSCode's powershell terminal, opens a separate cmd.exe
console window which seems to run the script in git bash. So this might be a git bash issue.