How to map the current directory?

I am trying to modify a Dockerfile that contained a command

docker container run --rm \
-v "$PWD":/home/gradle/project \
-v "$HOME"/.gradle-docker:/root/.gradle \
...

to be usable on Windows.
I replaced the $HOME by “~” which amazingly was accepted. Whether it also works still remains to be seen. If not I will try %HOME%.

But since there is no “PWD” env-variable in windows I wanted to replace that with “.” (i.e. the current directory), but then docker barfs at me:

docker: Error response from daemon: create .: volume name is too short, names should be at least two alphanumeric characters.

IMHO that check for >=2 characters is simply wrong! I guess the programmer had “C:” or something similar as minimal path in mind. But ‘.’ is a perfectly valid path!

How do I trick docker to accept “.” as valid directory?

2 Likes

did you find an answer to this?

Use $(pwd):/home/gradle/project

Did you try with “./” instead of “.”

The docker command needs absolute path to bind mount a folder or a file from the host. . or ./ will not work.
@daashuun gave the right answer more than a year ago, but that works only in PowerShell (And also in Bash on Linux)

In a command line %CD% contains the path of the current directory