Reputation: 3182
I noticed by accident that it doesn't make a difference whether I advertise a VOLUME in the Dockerfile or not. (The Oracle database xe18.4 lacks the VOLUME statement) When I docker run -v ...
the volume gets created without error.
What's the purpose of advertising a VOLUME in the Dockerfile if it can be omitted just as well?
Upvotes: 0
Views: 26
Reputation: 312370
What's the purpose of advertising a VOLUME in the Dockerfile if it can be omitted just as well?
It means that when you run the container, any files created at that location are stored in a volume, rather than in the container root filesystem. This means that those files can be shared with other containers using e.g. --volumes-from
(or an explicit reference to the volume).
It's also an explicit source of documentation -- if you want to persist storage beyond the lifecycle of your container, the VOLUME
directive is telling you where you should mount your named volume or bind mount.
Upvotes: 1