简体   繁体   English

在Bluemix容器上安装卷并在它们之间共享不起作用

[英]Mounting volumes on Bluemix containers and sharing between them does not work

I've created a volume with 我已经建立了一个

$ cf ic volume create mosquitto_config

This information shows up as expected: 此信息按预期显示:

$ cf ic volume list
mosquitto_config

Then, I've created two containers that are based on an image, which contains the VOLUME ["/etc/mosquitto"] line in its Dockerfile, and on which I'm able to log in via SSH: 然后,我创建了两个基于图像的容器,该容器在其Dockerfile中包含VOLUME ["/etc/mosquitto"]行,并且可以通过SSH登录该容器:

$ cf ic run -p 22:22 --volume mosquitto_config:/etc/mosquitto --name ssh-test registry.ng.bluemix.net/{reg-name}/{image-name}:latest
$ cf ic run -p 22:22 --volume mosquitto_config:/etc/mosquitto --name ssh-test-2 registry.ng.bluemix.net/{reg-name}/{image-name}:latest

After logging in, I see the mount point /etc/mosquitto as directory on both containers. 登录后,我将挂载点/etc/mosquitto视为两个容器上的目录。 However, if I create a file in that directory within one container, the new file does not show up in the other container. 但是,如果我在一个容器中的该目录中创建文件,则新文件不会显示在另一个容器中。 As far as I understand the volume concept, the new file should show up in the other container. 据我了解的卷概念,新文件应显示在另一个容器中。 Is it currently not working or how do you set it up correctly? 它当前无法正常工作还是如何正确设置?

this kind of way to share volumes I think is not supported by docker. 我认为docker不支持这种共享卷的方式。

In order to give a container access to another container's volumes, you can simply give the –volumes-from argument to docker run. 为了使一个容器能够访问另一个容器的卷,您可以简单地将–volumes-from参数赋予docker run。 For example: 例如:

$ docker run -it -h NEWCONTAINER --volumes-from container-test debian /bin/bash

All the volumes mounted in 'container-test' will be available to 'NEWCONTAINER' (with the same mount options) 在“容器测试”中安装的所有卷将对“ NEWCONTAINER”可用(具有相同的安装选项)

It's important to note that it works even if the container-test is not running: a volume will never be deleted as long as a container is linked to it. 重要的是要注意,即使容器测试未运行,它也可以工作:只要容器链接到某个卷,它就永远不会被删除。

For further help check this url http://container-solutions.com/understanding-volumes-docker/ 如需进一步的帮助,请检查此URL http://container-solutions.com/understanding-volumes-docker/

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

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