0

I require a fair bit of RAM and disk for a Docker container that will run infrequently as a task on ECS. My workflow:

  1. Start EC2 instance for ECS
  2. Run task on ECS
  3. Terminate EC2 instance

I terminate the instance between runs because these resources are relatively expensive, and I don't want them running when not in use. Fargate is not appropriate due to its resource limitations, so I'm running ECS on EC2.

I cannot get more than 30GB disk for the image without a lot of human intervention. I can attach arbitrary EBS data volumes (/dev/xvdcz), but AWS still always creates a 30GB root volume /dev/xvda which is used for the container itself.

How do I use a larger than 30GB volume for the Docker container itself?

What I've tried:

  1. Creating an Auto Scaling Group with a launch configuration where the root volume is larger. This does create an instance with a larger root volume, but there is no way to attach this group to a cluster, or link its created EC2 instance with the cluster. Cluster creation seems to be tied to an auto scaling group and instance.
  2. Using an instance with a large dedicated SSD rather than an EBS volume, again the 30GB partition is created for the container.
  3. Mounting dev/xvdcz to the container. This does add the space, but requires me to rewrite my code to only use this folder.
  4. Using the AWS ECS cli to modify disk after creation. This is described in a similar issue. However, as my EC2 instance terminates after task completion, the ID does not persist between runs, and aws ecs describe-clusters does not specify the underlying EC2 instance, so this cannot be automated. A human needs to boot up the instance, look at the ID, and then the volume size can be modified via the CLI.

This issue was brought up on Github back in 2016 but marked as not important and closed, the discussion there is not very helpful.

Student
  • 522
  • 1
  • 6
  • 18

1 Answers1

0
  1. Under EC2 > Auto Scaling, create a new Auto Scaling Group with a launch config that has your chosen root volume size. This will boot up an EC2 instance by default, leave it for now.
  2. Go to your cluster's auto-created Auto Scaling Group, note the name down (need it later), then click Launch Template > Edit. If it says 'launch configuration,' press 'switch to launch template.'
  3. Select your previously created Auto Scaling Group's template (note if you created multiple versions, select the latest, version 1 is selected by default). Select 'adhere to launch template' and click 'update.'
  4. Delete the Auto Scaling group you first created. This will shut down its related EC2 instance.
  5. Reboot your cluster's ec2 instance:
    aws autoscaling set-desired-capacity --auto-scaling-group-name NAME_OF_GROUP --desired-capacity 0
    
    Wait for it to shut down, you can see instance state in the EC2 console.
    aws autoscaling set-desired-capacity --auto-scaling-group-name NAME_OF_GROUP --desired-capacity 1
    
    Again wait for it to boot up. Once booted, and for any subsequent boots, /dev/xvda will be the size you specified.
Student
  • 522
  • 1
  • 6
  • 18