VOLUME
The Dockerfile instruction that marks a path as holding data that should live in a volume rather than the container layer.
In more detail
If you run the image without mounting anything there, Docker creates an anonymous volume at that path. It cannot be undone by later images built on top, so use it sparingly, typically for database data directories.
Example
VOLUME /var/lib/postgresql/dataRelated terms
- volume — Storage managed by Docker that lives outside any container, so data survives when the container is removed.
- writable layer — The thin layer on top of an image where a running container writes its changes.
Taught in
- ARG, ENV, LABEL, EXPOSE And VOLUME — Docker Architecture & Production Containers
- Twelve Lines, Ten Warnings: Dockerfile Instructions And hadolint — Docker Certified Associate (DCA) Exam Prep
- Images Sprint: Eight Questions On Builds, Tags And Registries — Docker Certified Associate (DCA) Exam Prep
- Orders That Vanished: Volumes, Shared Storage And Cleanup — Docker Certified Associate (DCA) Exam Prep