Careeroza
Health Checks & Restart Policies
HEALTHCHECK
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
CMD curl -fsS http://localhost:8000/health || exit 1Example (status)
docker ps --format "table {{.Names}}\t{{.Status}}"Example output
NAMES STATUS api Up 2 minutes (healthy)
Restart Policies
| Policy | Restarts the container... |
|---|---|
no (default) | never |
on-failure[:5] | when it exits with an error (max 5 times) |
unless-stopped | always, unless you stopped it manually |
always | always, also after the Docker daemon restarts |
docker run -d --restart unless-stopped myapi:1.0