Answers: <p>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.</p>
  
  <p>These ECS tasks can be scheduled via a cron-like job setup or on a CloudWatch event response:</p>
  
  <p><a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html" rel="nofollow noreferrer">https://docs.aws.amazon.com/AmazonECS/latest/developerguide/scheduled_tasks.html</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-01-23T19:51:56.440Z
Answers: 2020-01-23T19:51:56.440Z
Answers: Dennis Ruiz
Body: <p>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?</p>
  
  <p>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.</p>
  
Tags: <docker><amazon-web-services><amazon-ecs><databases><fargate>
Title: RDS DB migrations using ECS and Fargate
UserDisplayName: ajyvardan
ThreadText: # RDS DB migrations using ECS and Fargate
  
  (Asked by: username_0 on 2020-01-23)
  
  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.
  
  **Tags:** docker, amazon-web-services, amazon-ecs, databases, fargate
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-23. Score: 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>
  
  
  ---
  
  