Get health information from your running containers
Get health information from your running Docker containers instantly. This article shows a bash script using docker ps and docker inspect for quick checks.
This article is over a year old but was reviewed on July 30, 2026 — the content is still accurate.

This article shares a Bash script that loops over all Docker containers (docker container list --all) and reports each one's health status via docker inspect's State.Health field, giving a quick overview of which containers are healthy, unhealthy, or have no healthcheck configured (null).
When you've a few runnings containers on your machine, you can quickly retrieve the health information using docker ps and its State.Health response.
In this article, we'll look at how to create a bash script that can be used as a basis for other needs.
The one-glance overview
Here is what I get on my machine, in one command:

I've a few containers running, a lot are healthy meaning that they're running and without any issue, I've two containers in a null state i.e. they are sleeping and none are stopped due to an error.
That's the whole point: one screen, and you know which container needs your attention.
The script that produces it
Please create somewhere on your disk, in a Linux console, a script f.i. called health.sh with this content:
#!/usr/bin/env bash# Intentionally no "errexit": one container's failed inspect shouldn't stop the# whole list from being checked.set -o nounset -o pipefail
GRAY=30GREEN=32RED=31
clear
printf "\e[1;33m%s\e[0m\n\n" "Docker containers - Health check"
docker container list --all --format "{{.Names}}" | while read -r name; do healthcheckStatus=$(docker inspect --format='{{json .State.Health}}' "$name" | jq -r '.Status')
# Default color COLOR=${GRAY}
if [[ "$healthcheckStatus" == "healthy" ]]; then COLOR=${GREEN} elif [[ ! "$healthcheckStatus" == "null" ]]; then COLOR=${RED} fi
printf "%-40s\e[1;${COLOR}m%s\e[0m\n" "$name" "$healthcheckStatus"doneThis script displays the health status of all Docker containers in a colored list. It loops through each container, checks its health status, and prints the name alongside the status in gray (no health check configured), green (healthy), or red (unhealthy or failed).
Make sure to make the script executable: chmod +x health.sh, then run it with ./health.sh.
Get the list of all containers
docker container list --all --format "{{.Names}}" return the list of all containers and only echo the column Name on the console.
Conclusion
A few lines of Bash, and the question "is everything still fine on this machine?" gets an answer in one look instead of a docker inspect per container. Don't hesitate to fine-tune the script to fit your needs.
This script gives you a snapshot, on demand. If you'd rather be notified when a service goes down, have a look at Self-hosted monitoring tool. And when a container is up but still unreachable from another one, Troubleshooting for Docker containers - Accessing the other one walks through the diagnosis, layer by layer.





