How do you handle database migrations when containers start?
AdvancedProductionResource Limits, Health & Reliability
Answer
Run migrations as a separate one-shot job (Compose service_completed_successfully, Kubernetes Job/initContainer, ECS task) rather than in every app replica's entrypoint, to avoid races and long boot times. Make migrations backward compatible (expand/contract) so old and new versions overlap during rolling deploys.
More on Resource Limits, Health & Reliability
How do you set memory and CPU limits, and what happens when they are exceeded?BeginnerWhat is the difference between `--cpus`, `--cpu-shares` and `--cpuset-cpus`?BeginnerWhat does `--memory-reservation` do?AdvancedHow do you diagnose an OOM-killed container?IntermediateWhy do JVM and Node services in containers need explicit memory flags?IntermediateWhat is CPU throttling, and how do you detect it?Advanced