gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:42:25 24 4
gpt4 key购买 nike

抱歉,我不确定正确的术语(因此,我将尝试全部使用它来阐明我的观点)。对不起, docker 还很陌生。

我需要一种方法来在容器之间进行[链接/挂载卷/卷_从]存储-但似乎无法弄清楚。我不想使用主机,因为我试图共享对大型s3存储桶的访问权限-也就是说,主机实际上无法存储所有副本。

docker-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.

因此,根据您的情况,您可以在 docker-compose.yaml容器中更新 web:
volumes_from:
- s3

引用:
Managing data in containers: Creating and mounting a data volume container

docker-compose.yml reference: volumes_from

关于amazon-s3 - Docker Compose-[link/mount volume/volume_from]在容器之间共享数据,不使用主机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32576600/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com