Docker Compose - [link / mount volume / volume_from]在容器之间共享数据,而不是使用主机

时间:2015-09-15 02:06:07

标签: amazon-s3 docker docker-compose

抱歉,我不确定正确的术语(所以我会尝试通过使用它来解决问题)。对不起,仍然是码头工人的新手。

我需要一种在容器之间[link / mount 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

1 个答案:

答案 0 :(得分:1)

您可以使用选项$ 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.

docker-compose.yaml

因此,在您的情况下,您可以更新容器web中的volumes_from: - s3

bookings

参阅: Managing data in containers: Creating and mounting a data volume container

docker-compose.yml reference: volumes_from