部署 Dockerfile VOLUME 挂载后为空,有遇见过这个问题的么

yingce · December 12, 2016 · Last by yingce replied at December 13, 2016 · 3912 hits

已经在 Dockerfile 写好 VOLUME /data
使用 run -v 挂载没问题,用 VOLUME 构建的镜像不行,会是空的

df 的信息

Filesystem                 Size  Used Avail Use% Mounted on
none                        23G  8.4G   13G  41% /
tmpfs                      2.5G     0  2.5G   0% /dev
tmpfs                      2.5G     0  2.5G   0% /sys/fs/cgroup
/dev/mapper/ruby--vg-root   23G  8.4G   13G  41% /data
shm                         64M     0   64M   0% /dev/shm
yingce closed this topic. 12 Dec 18:04
yingce reopened this topic. 12 Dec 18:04

#3 楼 @huacnlee 我使用 dockerfile build 出来的镜像 然后 docker run 出来的实例并没有挂载相应的目录

VOLUME 指令和 run -v 是不一样的,官方文档有说明

我记得 Build 成 Image 的时候,路径的 VOLUMN 是无效的,因为谁知道 Docker Image 会用在什么环境下面,有没有那个路径

#6 楼 @huacnlee 恩,我也想过这个问题;因为多机的情况下都挂在宿主机的目录那就有问题了。但是这样看的话不知道 VOLUME 是什么作用,再去翻翻文档,谢了

You need to Sign in before reply, if you don't have an account, please Sign up first.