willfarrell / docker-autoheal

Monitor and restart unhealthy docker containers.
MIT License
1.31k stars 225 forks source link

"true" must be quoted in docker compose: documentation issue? #110

Open reinout opened 1 year ago

reinout commented 1 year ago

I have a mix of services with only some of them having a health check. So I configured autoheal like this in my docker-compose.yml:

autoheal:
  image: willfarrell/autoheal:1.1.0
  tty: true
  restart: unless-stopped
  environment:
    - AUTOHEAL_CONTAINER_LABEL=autoheal
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock

And the services with healthcheck got the label:

geoserver:
  image: ...
  labels:
    autoheal: true

Autoheal didn't seem to be working for me. No logs. Well, the instances that could need to be autohealed rarely failed, which is good news, but made it harder to see if autoheal was working.

It turned out that autoheal: true was the problem. true needs to be quoted: autoheal: "true", as autoheal searches for the lowercase value. Just true gets translated to a True boolean by docker compose, which autoheal doesn't search for.

So....

reinout commented 1 year ago

Unrelated to the documentation issue... I could probably have omitted the label entirely in my case? I only used it to restrict autoheal to my containers with a health check, preventing autoheal from looking at the non-health-check containers. Autoheal searches for {"health": "unhealthy"}, so containers without a health check are completely ignored in any case, it seems.

hasnat commented 1 year ago

this certainly can be an annoying, I recall docker-compose has got tendencies to do conversions on yml which IMO it shouldn't. I'd be nice to turn autoheal check to 1/True/true/yes like.