brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: healthcheck disable: true switches off a Docker image's built-in health check

Docker
~/tips/tip-docker-compose-healthcheck-disable

disable: true

Turn off an image's own health check when it does not fit your setup.

Some images ship a HEALTHCHECK that assumes a default port or path. Change the app’s port and the container is marked unhealthy forever, even though it works. You can switch the check off per service.

services:
  app:
    image: example/app:1.0
    healthcheck:
      disable: true

This is the same as test: ["NONE"], and on the command line docker run --no-healthcheck does the job. After recreating the container, docker ps no longer shows (healthy) or (unhealthy) in the status column.

To see what the image wanted to check before you turn it off, I’d look at the image config:

docker image inspect --format '{{json .Config.Healthcheck}}' example/app:1.0

Often the better fix is to override the check rather than drop it. Writing your own healthcheck: with the right port keeps the benefits.

Turning it off has knock-on effects. Another service with depends_on and condition: service_healthy on this one will refuse to start, because a container without a health check can never become healthy. docker compose up --wait then only waits for the container to be running.

Further reading: Compose file reference: healthcheck, Dockerfile reference: HEALTHCHECK

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link