【问题标题】:Docker Compose - [link/mount volume/volume_from] sharing data between containers, not using hostDocker Compose - [link/mount volume/volume_from] 在容器之间共享数据,不使用主机
【发布时间】:2015-09-15 02:06:06
【问题描述】:

对不起,我不确定正确的术语(所以我会尝试通过使用它来表达我的观点)。抱歉,对 docker 还是新手。

我需要一种方法来在容器之间[链接/装载卷/volume_from] 存储 - 但似乎无法弄清楚。我不想使用主机,因为我正在尝试共享对大型 s3 存储桶的访问权限 - 即主机物理上无法存储所有内容的副本。

docker-compose.yml

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

s3:
  image: xueshanf/s3fs

【问题讨论】:

    标签: amazon-s3 docker docker-compose


    【解决方案1】:

    您可以使用一个选项--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
    

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

    docker-compose.yml reference: volumes_from

    【讨论】:

    • 感谢@BMW,请问您将如何从 Web 容器访问数据?它会位于哪里?
    猜你喜欢
    • 1970-01-01
    • 2017-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多