简体   繁体   English

防止在docker运行时创建卷

[英]Prevent volume creation on docker run

Dockerfile can contain VOLUME /path instruction. Dockerfile可以包含VOLUME /path指令。 That means that when docker run is executed, docker creates automatically a volume and binds it to /path inside container. 这意味着当执行docker run时,docker会自动创建一个卷并将其绑定到容器内的/path

I'd like to skip the automatic volume creation in some cases. 在某些情况下,我想跳过自动卷创建。 Is that possible somehow? 这有可能吗?

Not once it's be added to the Dockerfile. 不是一旦它被添加到Dockerfile。 I'd personally avoid doing volumes inside of the Dockerfile since it ends up creating anonymous volumes as you've seen, but also because it breaks attempts to modify that directory in child images or even later steps inside of the same Dockerfile. 我个人避免在Dockerfile中编写卷,因为它最终会像你看到的那样创建匿名卷,但也因为它破坏了在子映像中修改该目录的尝试,甚至是在同一个Dockerfile内部的后续步骤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM