"Remove" a VOLUME in a Dockerfile

You may overwrite files. Use multistage build and COPY (docker 19.03). One stage Create files outside of VOLUME'd folder. Or at same RUN step which add/modify files copy it outside of that folder. Next stage COPY files from previous stage to VOLUME'd folder.


No.

The only way to do so, is if you clone Dockerfile of the image you use as base one (the one in FROM) and remove the VOLUME directive manually. Then build it and use in your FROM as base one.


There are cases when you can not modify the original Dockerfile - in my case an image from production. The only chance is to modify the metadata (with docker save/load actions). As I need to that regulary, I have created a little script for that, have a look at docker-copyedit if that can help you.