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