What are `stop_grace_period`, `stop_signal` and `init` in Compose?
IntermediateProductionResource Limits, Health & Reliability
Answer
services:
api:
image: api:1.4.2
init: true
stop_signal: SIGTERM
stop_grace_period: 45s
restart: unless-stopped
deploy:
resources:
limits: { cpus: "1.0", memory: 512M }
These map to --init, --stop-signal, --stop-timeout, --restart and cgroup limits.
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