Home > Mobile >  Update task's container in ECS services
Update task's container in ECS services

Time:10-01

I have an ECS service with a task definition that has three containers:

  • Frontend container
  • Backend container
  • MongoDB container

I would like to update the frontend container and/or the backend container without loosing the mongoDB data.

what would be the best way to do it?

Is it possible to update the service without redeploy the entire task (and loosing the db data) but only the container(s) I need?

Should I use a bind volume for the mongo db so I can save the data there and when the service is redeployed the new mongo db container will retrieve the data from there?

Hope that make sense. Thanks in advance.

CodePudding user response:

what would be the best way to do it?

Ideally you wouldn't be running MongoDB in the same Task. You would be running it in a separate ECS task (or just running it on an EC2 instance directly). Right now you can't scale-out your frontend/backend services because doing so would spin up the new service instances with a new, empty database.

Is it possible to update the service without redeploy the entire task (and loosing the db data) but only the container(s) I need?

No that's not possible

Should I use a bind volume for the mongo db so I can save the data there and when the service is redeployed the new mongo db container will retrieve the data from there?

If you are deploying your ECS tasks to EC2 targets, then you could use a bind mount that would store the DynamoDB data on one of the EC2 instances in your cluster. However if that EC2 instance ever went down you would still lose all your data. The more fault-tolerant and highly-available method would be to bind an EFS volume to your MongoDB container to store the data.

If you are deploying your ECS tasks to Fargate, then bind mounts would not be an option, EFS would be the only option.

  • Related