3 Answers
Hi Rahul,
Normally, its not good practice to mount a foreign volume from within a Docker container….they should be transient and where persistence is needed, you’d normally use a local path on the Docker server host. Fargate makes things more interesting since you don’t manage the Docker server host. AWS specifically says that Fargate task storage is ephemeral…kind of treat containers on Fargate as stateless.
Depending on your need for persistence, you could build storage into your container app to save stuff to Dynamo, RDS or S3. I have seen people using a script to download and upload data from their ECS Fargate-managed container to S3 for persistence. You can find a few example out on StackExchange and Github.
–Scott
I don’t agree stateless means ephemeral storage only. It’s okay to have completely stateless containers and still use some shared volume to read and write data. This is not making containers statefull. I will be not surprised if AWS adds EBS volumes mount option to Fargate tasks as well!
Regarding ECS service only EC2 instances can support persistent volumes (docker volumes), Fargate currently is out of scope.
Fargate now supports persistent storage using EFS volumes [https://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html]
Can you please clarify your question or explain scenario?