How can I increase disk space for my Amazon ECS container on Fargate?

Last updated: 2020-12-17

I want to increase disk space for my Amazon Elastic Container Service (Amazon ECS) container on AWS Fargate.

Short description

By default, Fargate tasks that are launched with platform version 1.40 include a task storage size of 20 GB as a single ephemeral volume. Tasks using the Fargate launch type include Amazon Elastic File System (Amazon EFS) file system support for platform version 1.4.0 or later. For more information, see Available AWS Fargate platform versions.

If the underlying container host machine runs out of disk storage, then you see the "No space left on device" error message. This means that your application workload running inside the container requires large or persistent storage to process large datasets and files. You can solve this error by integrating Fargate tasks with Amazon EFS volumes.

Important: When you create an Amazon EFS volume, use the same Amazon Virtual Private Cloud (Amazon VPC) and subnets that are assigned to your Fargate service.


1.    Create a security group for your Amazon EFS mount targets, and then add an inbound rule to accept NFS traffic on port 2049 from the source's task security group.

2.    Create an Amazon EFS file system, and then attach the security group from step 1 to your mount targets.

Note: By default, a mount target is configured in each Availability Zone in a given AWS Region. Select all the Availability Zones where the VPC subnets for the Fargate service are located.

3.    Note the file system ID of your file system (for example, fs-12345678).

4.    Create or update a task definition to configure a volume for the Amazon ECS task that has your Amazon EFS file system. For example:

"volumes": [ 
      "name": "efs-test-volume",
      "efsVolumeConfiguration": {
           "fileSystemId": "fs-12345678", 
           "transitEncryption": "ENABLED" 

Note: Replace fs-12345678 with your file system ID.

5.    Use a container definitions section to create a mount point for the volume inside your container. For example:

"containerDefinitions": [ 
   "memory": 128, 
    "portMappings": [ 
          "hostPort": 80, 
          "containerPort": 80, 
           "protocol": "tcp" 
     "essential": true, 
     "mountPoints": [ 
        "containerPath": "/mount/path/inside/container", 
        "sourceVolume": "efs-test-volume" 
      "name": "nginx", 
      "image": "nginx" 

Note: The containerPath is the path inside the container where you mount the volume. The sourceVolume should be the same name of your volume as defined in step 4.

6.    Run the task using your updated task definition.

Note: For tasks that are associated with service, update the service by selecting a new task definition revision.

Did this article help?

Do you need billing or technical support?