qdm12 / deunhealth

Binary program to restart unhealthy Docker containers
MIT License
124 stars 8 forks source link

Recognition of "deunhealth.restart.on.unhealthy" #48

Open pirh2o opened 2 years ago

pirh2o commented 2 years ago

I've running the latest version of deunhelath in a docker container through docker-compose stack. The version of docker and compose are the latest as well. In the stacks of the containers that I want to restart when becoming unhealthy, I've added the label as follows:

labels:
  deunhealth.restart.on.unhealthy: true

Despite the containers work fine and labels have been added correctly, deunhealth does not seem to recognise the labels, being the deunhealth's log as follows:

2022/06/25 14:00:23 INFO healthcheck: listening on 127.0.0.1:9999
2022/06/25 14:00:23 INFO Monitoring 0 containers to restart when becoming unhealthy
2022/06/25 14:00:23 INFO New labeled containers will be automatically detected

I don't know if I'm doing something wrong.

Thanks in advance.

qdm12 commented 2 years ago

Can you share your deunhealth full logs and docker-compose.yml please?

pirh2o commented 2 years ago

All my logs are these:

========================================

============== deunhealth ==============

=========== Made with ❤️ by ============ =========== github.com/qdm12 ===========

========================================

Running version latest built on 2021-11-28T12:51:56Z (commit 6f26ebf)

🔧 Need help? https://github.com/qdm12/deunhealth/discussions/new 🐛 Bug? https://github.com/qdm12/deunhealth/issues/new ✨ New feature? https://github.com/qdm12/deunhealth/issues/new ☕ Discussion? https://github.com/qdm12/deunhealth/discussions/new 💻 Email? quentin.mcgaw@gmail.com 💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12 2022/06/27 18:34:18 INFO healthcheck: listening on 127.0.0.1:9999 2022/06/27 18:34:18 INFO Monitoring 0 containers to restart when becoming unhealthy 2022/06/27 18:34:18 INFO New labeled containers will be automatically detected

And my docker-compose is:

version: "3.7" services: deunhealth: container_name: deunhealth image: qmcgaw/deunhealth volumes:

Thanks again. Regards.

pirh2o commented 2 years ago

When the label "deunhealth.restart.on.unhealthy" is created manually, it works. The problem is doing one by one for each container.

Freekers commented 2 years ago

I have exactly the same issue on Raspberry Pi 3b (ARM_V7). Does not work when labels are created using docker-compose, have to add them manually.

teodorescuserban commented 2 years ago

Make sure you are using one of these two modes to add the label in the docker-compose:

...
    labels:
      deunhealth.restart.on.unhealthy: "true"
...

or

...
    labels:
      - deunhealth.restart.on.unhealthy=true
...

Do not use this way:

...
    labels:
      deunhealth.restart.on.unhealthy: true
...

because docker-compose would replace the boolean true with "True" and that would not work it seems.

Perhaps deunhealth could check for all variants?

martindmtrv commented 1 month ago

Yeah I just had this issue and changing to the string seemed to fix it.

Though it is not obvious why this happens, when running docker container inspect on the container before and after I see the same output for both. Maybe the api that is used to pull the docker output knows the difference

with boolean true in the label "deunhealth.restart.on.unhealthy": "true",

With string "true" "deunhealth.restart.on.unhealthy": "true",