Docker Compose – 在容器之间共享数据,不使用主机

对不起,我不知道正确的术语(所以我会试着通过使用这一切来得到我的观点)。 对不起,泊坞窗还是新的。

我需要一种方式来[在容器之间链接/挂载volume / volume_from]存储 – 但似乎无法弄清楚。 我不想使用主机,因为我试图共享一个大的s3桶 – 即主机物理上不能存储所有的副本。

泊坞窗,compose.yml

web: hostname: web image: mprasil/webdav ports: - "80:80" links: - s3 volumes: - /local/dir/:/site/input/ s3: image: xueshanf/s3fs 

有一个选项--volumes-from可以使用。

 $ docker create -v /dbdata --name dbdata training/postgres /bin/true You can then use the --volumes-from flag to mount the /dbdata volume in another container. $ docker run -d --volumes-from dbdata --name db1 training/postgres And another: $ docker run -d --volumes-from dbdata --name db2 training/postgres In this case, if the postgres image contained a directory called /dbdata then mounting the volumes from the dbdata container hides the /dbdata files from the postgres image. The result is only the files from the dbdata container are visible. You can use multiple --volumes-from parameters to bring together multiple data volumes from multiple containers. 

所以在你的情况下,你可以更新容器web docker-compose.yaml

 volumes_from: - s3 

请参阅: pipe理容器中的数据:创build并装入数据容器

docker-compose.yml参考:volumes_from