Skip to content

depends_on and healthchecks

Select an icon to see what it is.

Step 3 of 6

Exit code 0 means healthy

pg_isready exits 0 when the server accepts connections, and 2 when it does not answer. Once a run exits 0, dockerd sets the status to healthy. On a first start postgres runs a short setup server on its socket, so an early pass is possible.

docker inspect (State.Health)

{
"State": {
"Health": {
"Status": "healthy"
"FailingStreak": 0
"Log": [
{
"ExitCode": 0
"Output": "/var/run/postgresql:5432 - accepting connections"
}
]
}
}
}