Interview Prep/Docker/Dockerfile Instructions & Builds

How does `VOLUME` in a Dockerfile behave?

IntermediateConceptDockerfile Instructions & Builds
Answer

It declares a mount point; at run time Docker creates an anonymous volume there if you do not mount something. Any changes to that path in later Dockerfile steps are discarded (the path is frozen once declared), and the pile of anonymous volumes is a classic disk leak. Many teams avoid VOLUME and define mounts at run time.

All Docker questions Roadmap: Docker & containers

More on Dockerfile Instructions & Builds