“Remove” a VOLUME in a Dockerfile

后端 未结 3 1664
-上瘾入骨i
-上瘾入骨i 2020-12-18 18:13

I have a Dockerfile extending FROM an image that declares a VOLUME. Is there a way to overwrite the VOLUME directive in such a way, th

相关标签:
3条回答
  • 2020-12-18 18:49

    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.

    0 讨论(0)
  • 2020-12-18 19:06

    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.

    0 讨论(0)
  • 2020-12-18 19:11

    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.

    0 讨论(0)
提交回复
热议问题