I have been watching a tutorial video, and in my case I mount a local dir like so:
docker run -it --rm --name videodownloaderweb --env-file env.list -v /mnt/share:/data
And this lets me mount /mnt/share (which is a virt-manager shared folder from vm host) to /data within the container. The Docker documentation outlines this use case clearly at: docker run | Docker Docs
But, whilst watching this tutorial, the Youtuber gave a second use case which is undocumented as far as I can see? My command is now:
docker run -it --rm --name videodownloaderweb --env-file env.list -v /mnt/share:/data -v "$(pwd):/app" -v /app/node_modules --user 1000:1000 -p 3000:3000 videodownloaderweb /bin/sh
-v “$(pwd):/app” lets me mount my local node.js development files and static files directly over the /app directory within the container. The issue also addressed here is that we don’t want to mount the host ./node_modules directory within the container as these files are specific to the host and no where else. So what is needed is to use the container created “node_modules” in place inside the container. This is achieved in the above command line with: “-v /app/node_modules”. Note that this mount spec is missing a colon, and the source and only references the dest container folder which exists already in the docker image (created during image build). What this does is just use the existing container folder and doesn’t attempt to mount any host directory over it. It’s almost like an exclude/ignore option. Don’t believe this is an anonymous volume?
Can someone explain what this is called and where it is documented on the documentation?