DEV Community

Discussion on: Learn Docker - from the beginning, part II volumes

Collapse
 
tssidhu profile image
tssidhu • Edited

Very helpful article and thanks for taking time to put it together. I had a question about the last docker run command. Shouldn't that include an image name at the end? The version I see currently is:

docker run -d -p 8000:3000 --name my-container --volume $(PWD):/app
Enter fullscreen mode Exit fullscreen mode

But, when I use that in my machine, I get "docker run" requires at least 1 argument. Only way I was able to fix it was by adding the image name at the end.

docker run -d -p 8000:3000 --name my-container --volume "%cd%":/app chrisnoring/node
Enter fullscreen mode Exit fullscreen mode

NOTE: "%cd%" is being used instead of $(PWD) since it's a windows machine

Collapse
 
softchris profile image
Chris Noring

Hey. You are completely right. Sorry, you had to lose time over this and thank you for posting this correction, I've updated the article.

Collapse
 
denniswebdel profile image
dennisFS

also worth adding that if you are on windows using git bash the path conversion gets messy so that command substituition needs to be escaped like this:
~> docker run -d -p 8000:3000 --name EXAMPLE --volume /$(pwd)/logs:/logs YOUR_IMAGE

Collapse
 
bijoy26 profile image
Anjum Rashid

For me (in windows git bash), I also had to wrap around with "" to make it work.

$ docker run -d -p 8000:3000 --name YOU_NAME --volume /"$(pwd)"/logs:/logs YOUR_IMAGE