How to mount EFS inside a docker container?

a 夏天 提交于 2020-04-30 10:04:06

问题


I am trying to mount EFS inside a docker container running on EC2 server. EFS mount in EC2 is working fine with,

sudo mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2,noresvport <efs-address>:/ efs

But when tried in docker container, it is giving error 'mount.nfs4: Operation not permitted'. Please let me know how to achieve this.


回答1:


You can create a docker volume using EFS:

docker volume create \
    --driver local \
    --opt type=nfs \
    --opt o=addr=10.0.0.50,rw,nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 \
    --opt device=:/ efs 

Then mount the volume docker run --rm -it -v efs:/mnt ubuntu:18.04.



来源:https://stackoverflow.com/questions/57708612/how-to-mount-efs-inside-a-docker-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!