willfarrell / docker-autoheal

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

Implemented restart retrying #102

Open tiomny opened 1 year ago

tiomny commented 1 year ago

This autoheal container watches for unhealthy containers and sends a restart command to unhealthy container when finds some. However, sometimes that container starts and fails again, or it fails to restart. This patch adds an ability to look after restarting container until it restarts successfully. AUTOHEAL_RETRIES container parameter was also introduced for maximum restart attempts.

modem7 commented 1 year ago

I would argue that if the container keeps on retrying, there's typically an underlying issue with the container itself, and not just a temporary condition.

Could you give an example where this has been an issue for you?

tiomny commented 1 year ago

In my case this is the HomeAssistant container. It crashes for some external reason, and the original Autoheal fails to restart it. More details: external reason is a VPN container, which restarts once a day. Its warm-up time might be a bit longer than HomeAssistant's, that's why HA crashes immediately after start. I put my changes directly into Autoheal and it restarts HA successfully at 2-3 attempt.

I would say that VPN might be offline temporarily for different reasons and my case is just a small individual case.

leleobhz commented 1 year ago

I would argue that if the container keeps on retrying, there's typically an underlying issue with the container itself, and not just a temporary condition.

Could you give an example where this has been an issue for you?

I generically can state race conditions with services - including other services healed by autoheal. A case is a webservice with healthcheck that leads on database connection and the database also dies.

Also, this PR may need to be refreshed from main branch.