Muhammad Sharif
Muhammad Sharif

Reputation: 466

Docker volume mapping folder issue on Windows 10

I am trying to run the following command

docker run -p 3000:3000 -v/app/node_modules -v $(pwd):/app 2ef0206fcf99

I am getting the following 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.

How can I fix the issue?

Upvotes: 0

Views: 1745

Answers (2)

Dashrath Mundkar
Dashrath Mundkar

Reputation: 9184

I also had the same issue on windows make sure that you put "$PWD" something like this so your command should be something like this

docker run --rm -it -p 3000:3000 -v "$PWD:/app" 2ef0206fcf99

or another way is

docker run --rm -it -p 3000:3000 --volume="$PWD:/app" 2ef0206fcf99

Upvotes: 2

Technext
Technext

Reputation: 8107

1) Using Windows Powershell, following works for me:

docker run --rm -it -v ${pwd}:/mydir nginx:latest bash

Note:

  • I have used curly braces around pwd instead of small braces

2) Using Git Bash, following syntax should work:

winpty docker run --rm -it -v "/$PWD":/mydir nginx:latest bash

Note:

  • If you do not use winpty at the start of the command, you will get error message: the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'

  • Also notice the / before $PWD. Without the /, it will not throw error but i noticed that it didn't mount the directory.

Upvotes: 2

Related Questions