The HEALTHCHECK instruction in a Dockerfile is a built-in mechanism to monitor container health. Let me break it down:
starting, healthy, or unhealthy)HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/healthCheck Command (curl --fail ...):
--fail makes curl return non-zero exit code on HTTP errorsDefault Timing (if not specified):
docker ps
CONTAINER ID STATUS PORTS NAMES
a1b2c3d4e5f6 Up 2 minutes (healthy) 0.0.0.0:8501->8501/tcp pg-viewer
HEALTHCHECK --interval=1m --timeout=10s --start-period=30s --retries=3 \
CMD curl --fail http://localhost:8501/_stcore/health--interval: Time between checks (default: 30s)--timeout: Time before considering check failed (default: 30s)--start-period: Initial container startup time (default: 0s)--retries: Consecutive failures needed to mark unhealthy (default: 3)docker inspect --format='{{json .State.Health}}' <container-name>This helps ensure your database viewer remains operational and automatically flags issues if: - Streamlit process dies but container remains running - Application enters a zombie state - Server becomes unresponsive due to errors