How should stateful workloads (databases) be run in Docker?
AdvancedProductionResource Limits, Health & Reliability
Answer
Possible (named volumes on fast durable storage, resource limits, backups, tuned shm_size, stop timeout long enough for clean shutdown), but for production we usually prefer managed services (RDS, Cloud SQL) because backups, failover and patching are solved. Containerized DBs are great for dev/CI. If on Kubernetes use operators (CloudNativePG, etc.) and not hand-run volumes.
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