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.
Run Code Online (Sandbox Code Playgroud)
并且Dockerfile有VOLUME
指令
VOLUME ["/data"] - The VOLUME instruction will add one or more new volumes
to any container created from the image.
Run Code Online (Sandbox Code Playgroud)
从我看到的,host-dir
使用Dockerfile时无法指定或rw/ro状态.
除了想要与其他容器共享之外,在docker文件中是否还有其他VOLUME用途?
cre*_*ack 25
Dockerfiles是可移植和共享的.host-dir卷是100%依赖于主机的东西,并且会在任何其他机器上中断,这与Docker的想法有点不同.
因此,只能在Dockerfile中使用可移植指令.如果需要host-dir卷,则需要在运行时指定它.
Dockerfile中VOLUME的一个常见用法是存储配置或网站源,以便以后可以由另一个容器更新.
归档时间: |
|
查看次数: |
7282 次 |
最近记录: |