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

3 minute read

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 GiB as a single ephemeral volume. If you need more than 20 GiB of storage, you can configure more storage using two options:

  • Use Fargate's ephemeral storage option for storage up to 200 GiB. Ephemeral storage is non-persistent storage.
  • Use Amazon Elastic File System (Amazon EFS) volumes for scalable file storage. Amazon EFS volumes provide persistent storage.

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.


Configuring ephemeral storage

Note: If you receive errors when running AWS Command Line Interface (AWS CLI) commands, make sure that you’re using the most recent AWS CLI version.

For more examples of configuring ephemeral storage, see Bind mount examples.

Configuring storage with Amazon EFS volumes

1.    Create a security group for your Amazon EFS mount targets. 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 is the 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.

AWS OFFICIALUpdated 2 years ago