DEV Community

Discussion on: Creating an app with Docker Compose, Django, and Create React App

Collapse
 
englishcraig profile image
Craig Franklin

Thanks. The only time I use on-way volumes is for managing the node_modules directory. I don't know the internals well, but with a two-way volume, when you run docker-compose up, docker takes the files on your machine and inserts them in the newly-started container, overwriting any equivalent files that were in your image. This is usually what you want, so you don't have to rebuild the image every time you change your code, but the whole point of installing dependencies in an image is that they are independent of the machine running the container. Using a one-way volume prevents the node_modules directory on your computer from replacing the one in your docker image.