Notes on Docker Volume.
Table of contents
Open Table of contents
Introduction
When we’re actively working on our codebase we certainly want our changes to reflect immediately inside our running Docker container. Rebuilding the whole image after every tiny change is not an ideal solution. There comes the Docker volumes.
It’s a process identical to port mapping but for folders/directories.
Command
docker run -p 3000:3000 -v /app/node_modules -v $(pwd):/app {image-id}
Here
-v $(pwd):/app
: Maps the current working directory to/app
working directory inside container.-v /app/node_modules
: We signal Docker that don’t try to map this directory to the local directory. Use the one that’s there inside the container. See we don’t have used:
here for mapping so that will act as a placeholder.