Back to Directory
Stack Guides August 18, 2026

How to Monitor Docker Container Uptime and Health in Production

How to Monitor Docker Container Uptime and Health in Production

Docker has revolutionized application deployment by packaging runtimes, code, and dependencies into isolated container units. However, once containers are running in production, SRE teams must continuously monitor their availability, resource limits, and health.

A common pitfall is assuming that because a container state is "running," the application inside it is functioning correctly. If your app process deadlocks, the container will remain active while users encounter connection errors.

If you are asking: How do I monitor Docker container uptime and health? This guide covers native Docker commands, configuring image health checks, and deploying production monitoring pipelines.


1. Quick Terminal Diagnostics: The Native Commands

Docker provides built-in command-line tools to audit container resources and execution states in real time:

  • docker ps: Lists all active containers, including their status, launch times, and port mappings.
  • docker ps -a: Shows all containers, including stopped or crashed instances, helping you identify exit codes (e.g., Exit 137 indicates an out-of-memory crash).
  • docker inspect <container-id>: Returns detailed JSON metadata, including network configurations and volume bindings.
  • docker stats: Displays a live stream of resource usage statistics for all running containers:
# View live CPU, memory, and network metrics for all active containers
docker stats

# Monitor a specific container by name
docker stats my-web-app

2. Implementing Docker Health Checks

To verify that the application inside the container is actually working, define a custom HEALTHCHECK directive in your Dockerfile or Docker Compose configuration.

A health check executes a designated command inside the container at fixed intervals. If the command returns an exit code of 0, the container is declared healthy. An exit code of 1 indicates a failure.

Dockerfile Syntax Example

Add this directive to your Dockerfile to query your backend server's endpoint:

HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD curl -f http://localhost:8080/health || exit 1
  • --interval: The delay between health check executions.
  • --timeout: The maximum allowed duration for the command to complete.
  • --retries: The number of consecutive failures required to transition the container to the "unhealthy" state.

Once defined, running docker ps will display the container health state (e.g., Up 2 hours (healthy)).


3. Production Monitoring: Prometheus and Grafana

For larger container deployments, SRE teams integrate cAdvisor with Prometheus to build a centralized observability pipeline:

  1. cAdvisor (Container Advisor): A daemon utility by Google that collects, aggregates, and exports resource usage data (CPU, memory, network, file I/O) from all active containers on a host.
  2. Prometheus: Scrapes metrics from cAdvisor at regular intervals and stores them in a time-series database.
  3. Grafana: Connects to Prometheus to display visual dashboards and handle resource threshold alerts.

Common alerting rules in this setup include:

  • High Memory Alerts: Trigger a warning if a container's memory consumption exceeds 90% of its designated limit:

[\text{Memory Usage Ratio} = \frac{\text{Container Memory Used}}{\text{Container Memory Limit}} > 0.90]

  • Crash Loop Alerts: Notify SREs if a container restarts more than 3 times within a 10-minute window.

4. Simplified Monitoring with Pingzo

If you do not want to manage a complex Prometheus/cAdvisor stack, you can set up simple external checks to monitor your Dockerized apps:

  • Port Mapping Checks: When you run a Docker container, you expose internal ports to the host (e.g., mapping port 8080 inside the container to port 443 on the host). Configure Pingzo to monitor these public endpoints.
  • Decoupled Failure Detection: If the application process crashes or the Docker daemon halts, Pingzo will detect the connection drop and route an alert to your team.
  • WhatsApp Incident Delivery: Get detailed crash logs and downtime metrics delivered straight to your developers' WhatsApp threads, ensuring rapid incident response.

Combining Docker health checks for container runtimes with Pingzo for external route validation ensures total coverage for your containerized applications.

Summarize with AI

Instantly generate a summary of this page using your favorite LLM

pz-console
// Terminal
$npm install @pingzoapp/sdk
// Initialization Code
import { Pingzo } from '@pingzoapp/sdk';
const checker = new Pingzo({ apiKey: 'pz_live_...' });
[pingzo-agent] monitoring active: App
[pingzo-agent] status: 200 OK | latency: 85ms
DevOps Uptime Check

Uptime monitoring built for App developers

Configure HTTP health routes, inspect SSL status, and track cron workers from our console dashboard. Get direct texts on WhatsApp.

Start Monitoring Free