我可以指定要从Dockerfile装载的主机目录吗

我可以指定要从Dockerfile装载的主机目录吗,docker,Docker,Docker run命令具有将主机目录装载到容器中的选项 -v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. If "host-dir" is missing, then docker creates a new volume. Dockerfile有卷指令 VOLUME ["/data"] - The VOLUME instruction will add one or more new v

Docker run命令具有将主机目录装载到容器中的选项

-v=[]: Create a bind mount with: [host-dir]:[container-dir]:[rw|ro]. 
       If "host-dir" is missing, then docker creates a new volume.
Dockerfile有
指令

VOLUME ["/data"] - The VOLUME instruction will add one or more new volumes 
                   to any container created from the image.
在我看来,在使用Dockerfile时,无法指定主机目录或rw/ro状态


docker文件中的卷除了想与其他容器共享之外还有其他用途吗?

docker文件是可移植和共享的。host dir卷完全依赖于主机,在任何其他机器上都会中断,这与Docker的想法有点不符

因此,只能在Dockerfile中使用可移植指令。如果需要主机目录卷,则需要在运行时指定它


Dockerfile中的卷的一个常见用法是存储配置或网站源,以便以后可以由另一个容器更新。

那么当前目录和Dockerfile如何?它将始终是便携式的,感谢您解释为什么不提供此功能。现在我理解了设计理念,这是有道理的。不能说我喜欢,但我现在明白了。