1

I run my app with Docker and ECS. How can I handle database migrations? With fargate there doesn’t seem to be a way to SSH into the container to run any commands so I can’t run my RDS MySQL migrations by going into the container. I have some migrations to run at times, not for all deploys. Any advice?

I used to run my docker container in a EC2 box so I had the option to run a command inside the container once the container is up. I have migrated to ECS and Fargate now and I don't know how to handle it now.

1 Answer 1

2

If you already have the script/tool in place to execute the database migrations then what you might need is to run the tool/script once. AWS ECS allows to schedule the executions of tasks (containers), you can set it up in a way that the container can run just only once.

These ECS tasks can be scheduled via a cron-like job setup or on a CloudWatch event response:

https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.