Search code examples
amazon-web-servicesamazon-ecsaws-fargate

How is `tmp` folder managed when using ECS Fargate?


I'm currently running some containers on production using AWS Fargate. I'm running an application that from time to time populates some files to /tmp folder.

That said, I want to know what happens to this /tmp folder. Is this something managed by Fargate (by ECS Container Agent, for example) or is it something that I need to manage by myself (using a cronjob to clear the files there, for example)?

NOTE 1: One way to handle that is to use s3 to handle that kind of behavior, however, the question is to know how Fargate behaves regarding /tmp folder.

NOTE 2: I don't need the files in /tmp folder, they just happen to appear there, and I want to know if I need to remove them or if ECS will do that for me.

I couldn't find anything about that in documentation. If someone points that subjects on the docs, I would be happy to accept the answer.


Solution

  • if I understand your question correctly, it looks like you want more precise control over temporary storage within your container.

    I don't think there is anything special that ECS or Fagate does with /tmp folders on the FS within the container.

    However, docker does have a notion of a tempfs mount. This allows you to designate a path that allows you to avoid storing data on the containers host machine.

    https://docs.docker.com/storage/tmpfs/

    ECS and Fargate recently added support for the tmpfs flag:

    https://aws.amazon.com/about-aws/whats-new/2018/03/amazon-ecs-adds-support-for-shm-size-and-tmpfs-parameters/