问题描述
我难以理解VOLUME的其他优点()。
I am having it difficulty in understanding added advantage of VOLUME(https://docs.docker.com/engine/reference/builder/#volume) .
在Dockerfile中,可以使用mkdir创建目录。一旦创建目录,我们就可以处理它。为什么指定VOLUME(装载)并分配给该目录? VOLUME支架有什么优势?我试图在没有VOLUME的情况下理解我们会错过什么。
In Dockerfile one can have mkdir to create a directory. Once the directory is created we can have handle to it. why specify a VOLUME (mount)and assign to that directory? What advantage VOLUME mount gives? I am trying to understand here without VOLUME what will we miss.
对我来说,它看起来像一个冗余函数,但是我可能错了。
to me its looks like a redundant function , however I might be wrong.
推荐答案
在容器删除后我们不想丢失数据时,卷非常有用。配置文件,数据库数据等。因此,您可以将同一卷与完整的新Docker容器一起使用。如果仅在Dockefile中创建目录,则文件夹内的数据将与容器一起删除。
A volume is very helpful when we don't want to lose data once the container is deleted. A configuration file, a database data, etc. Hence, you are able to use the same volume with a complete new docker container. If you only create a directory within the Dockefile, the data inside the folder will be deleted toghether with the container.
这篇关于VOLUME命令在Dockerfile中做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!