首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用docker-compose本地挂载AWS EFS

使用docker-compose本地挂载AWS EFS
EN

Stack Overflow用户
提问于 2020-09-27 18:03:34
回答 2查看 1.6K关注 0票数 3

我想知道是否有一种简单的方法可以使用Amazon EFS (弹性文件系统)在本地docker-compose设置中作为卷进行挂载。

原因是,对于本地开发,创建的卷保存在我的笔记本电脑上-如果我要更换机器,我无法访问任何底层数据。云NFS可以解决这个问题,因为它可以随时从任何地方使用。

亚马逊网络服务文档(https://docs.aws.amazon.com/efs/latest/ug/efs-onpremises.html)似乎建议使用亚马逊网络服务直连/虚拟专用网络-有没有办法避免这种情况:在监听所有IP地址的安全组中打开端口2049 (NFS流量),并将该安全组应用于新创建的EFS?

这是我的docker-compose.yml:

代码语言:javascript
复制
version: "3.2"
 
services:
  postgres_db:
    container_name: "postgres"
    image: "postgres:13"
    ports:
      - 5432:5432
    volumes:
      - type: volume
        source: postgres_data
        target: /var/lib/postgresql/data
        volume:
          nocopy: true
    environment: 
      POSTGRES_USER: 'admin'
      POSTGRES_PASSWORD: "password"
 
volumes: 
  postgres_data:
    driver_opts:
      type: "nfs"
      o: "addr=xxx.xx.xx.xx,nolock,soft,rw"
      device: ":/docker/example"

我得到以下错误:

代码语言:javascript
复制
ERROR: for postgres_db  Cannot start service postgres_db: error while mounting volume '/var/lib/docker/volumes/flowstate_example/_data': failed to mount local volume: mount :/docker/example:/var/lib/docker/volumes/flowstate_example/_data, data: addr=xxx.xx.xx.xx,nolock,soft: connection refused

我将其解释为我的笔记本电脑连接不是AWS EFS VPC的一部分,因此无法挂载EFS。

为了增加上下文,我希望对接web抓取设置,并将数据卷持久存储在云中,这样我就可以从任何地方连接到它。

EN

Stack Overflow用户

发布于 2021-11-03 07:22:21

代码语言:javascript
复制
volumes:
  nginx_test_vol:
    driver_opts:
      type: "nfs"
      o: "addr=fs-xxxxxxxxxxxxxxxxxx.efs.us-east-1.amazonaws.com,rw,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport"
      device: ":/nginx-test"

这使我很好地使用它。

票数 0
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64087211

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档