Amazon ECS
User Guide for AWS Fargate (API Version 2014-11-13)

Using Data Volumes in Tasks

  • To provide persistent data volumes for use with a container

  • To define an empty, nonpersistent data volume and mount it on multiple containers

  • To share defined data volumes at different locations on different containers on the same container instance

  • To provide a data volume to your task that is managed by a third-party volume driver

The lifecycle of the volume can be tied to either a specific task or to the lifecycle of a specific container instance.

When provisioned, each Fargate task receives the following storage. Task storage is ephemeral. After a Fargate task stops, the storage is deleted.

  • 10 GB of Docker layer storage

  • An additional 4 GB for volume mounts. This can be mounted and shared among containers using the volumes, mountPoints and volumesFrom parameters in the task definition.


    The host and sourcePath parameters are not supported for Fargate tasks.

For more information about Amazon ECS default service limits, see Amazon ECS Service Limits.

To provide nonpersistent empty storage for containers in a Fargate tasks

In this example, you may have two database containers that need to access the same scratch file storage location during a task.

  1. In the task definition volumes section, define a volume with the name database_scratch.

    "volumes": [ { "name": "database_scratch", "host": {} } ]
  2. In the containerDefinitions section, create the database container definitions so they mount the nonpersistent storage.

    "containerDefinitions": [ { "name": "database1", "image": "my-repo/database", "cpu": 100, "memory": 100, "essential": true, "mountPoints": [ { "sourceVolume": "database_scratch", "containerPath": "/var/scratch" } ] }, { "name": "database2", "image": "my-repo/database", "cpu": 100, "memory": 100, "essential": true, "mountPoints": [ { "sourceVolume": "database_scratch", "containerPath": "/var/scratch" } ] } ]