windowsdockercmd

docker run $(pwd) command invalid in Windows


I have to run a simple front-end app on docker with nginx. I'm following a tutorial that says to run in order:

docker build -t mytest
docker run -v $(pwd):/mnt -p 9090:9090 -w /mnt mytest ./scripts/tests.sh

the first command is ok, the app works fine. When I run the second one I have an error:

docker: Error response from daemon: create $(pwd): "$(pwd)" 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 'docker run --help'.

What is $(pwd)?

I read the doc about -v option but I don't understand the meaning of this variable.

I'm using Windows OS.


Solution

  • The cmd.exe equivalent to $PWD (which is what the tutorial should be recommending instead of the much less efficient $(pwd)) is %cd%

    Thus:

    docker run -v %cd%:/mnt -p 9090:9090 -w /mnt mytest ./scripts/tests.sh