Hi all. Beginner to docker here and really pleased with how it’s going. At the moment I’m learning about volumes and specifically mapping host > docker filepaths. One thing I can’t seem to figure is the local repo shortcode to map.
All works good if provide fullpath e.g. > docker run -v C:\Users\web1928\Documents\www\somefolder:/usr/share/nginx/html/:…
but I was trying to use path command without success > docker run -v $(pwd):/usr/share/nginx/html/:…
If I just command line $(pwd) it does return the fullpath string, so I figured it should work. Can anyone shed any light on the correct command for this?
pwd in Powershell is an alias to Get-Location. It works differently. If you don’t use it between quotation marks, it will return an output like above. You can try it:
pwd
echo $(pwd)
echo "$(pwd)"
You can use it this way with docker:
docker run -v "$(pwd):/usr/share/nginx/html/" ...
It was true, until they implemented it in Powershell so Linux users can use Powershell more easily
pwd is executable. $() is not, it executes a command, so you need an executable before it. Obviously, you don’t need $() to run pwd. It is required only to use its output as an argument of an other command. I just used echo for the example, so you could see the result.