Search code examples
amazon-web-servicesamazon-ec2amazon-ecsamazon-efs

Can we mount EFS on AWS ECS docker container?


I have an ECS instance on which my docker containers are running. I want to mount EFS on docker container which is running on ECS. Is it possible then how?

I am able to mount EFS on ECS instance but not on docker container which is running on ECS.

EFS is with direct connect & able to telnet it on 2049 port from docker.

mount -t nfs4 -o nfsvers=4.1,rsize=1048576,wsize=1048576,hard,timeo=600,retrans=2 X.X.X.X:/ /efs

Error is :- mount.nfs4: Operation not permitted


Solution

  • It should part of your task definition, you need to add the volumes in the task definition and then refer it in the source volume option, here is a tutorial from AWS.

    https://aws.amazon.com/blogs/compute/using-amazon-efs-to-persist-data-from-amazon-ecs-containers/

      "volumes": [
        {
          "name": "efs",
          "host": {
            "sourcePath": "/mnt/efs/mysql"
          }
        }
      ]