8

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.

William Martins
  • 1,969
  • 1
  • 18
  • 22

2 Answers2

7

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/

Roy Kachouh
  • 1,855
  • 16
  • 24
  • 1
    Thank you for your answer, it's helpful! However, the docs points out that `tmpfs` isn't supported in Fargate (https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_linuxparameters). Also, in the end of the day, I just need to know what happens if I never clean "/tmp" folder when using Fargate. Is it something managed by ECS/Fargate or it's something that I need to be aware to clean. I also think it does nothing with that, but I would like to confirm. :) – William Martins Mar 30 '18 at 21:18
  • 1
    Yes, ECS/Fargate will not do anything special with the /tmp folder. I would imagine the base container distribution you are building on top of will manage the /tmp directory similarly to how it's done on a host os. Which base image are you building on top of, perhaps that base os image will call out how it manages TMPDIR – Roy Kachouh Mar 31 '18 at 15:04
3

If I understand correctly, after your Fargate task ends its running, all the storage goes away.

According to aws documentation, a Fargate task receives some storage when provisioned, but it is an ephemeral storage.

So unless you are using a forever running task, you don't need to deal with temporary files. They will be gone with the storage.

I hope this helps.

Diego Grigol
  • 131
  • 6
  • 3
    Surely it helps, and it makes sense, however, my question at the time was really for some tasks that run for a long time, probably populating `/tmp` folder each hour with some content. But thanks anyway for your answer! – William Martins Apr 13 '19 at 19:08