In some cases, I need to restart other containers after deunhealth restarts the one with the deunhealth.restart.on.unhealthy label.
In order to do this, I added a new label deunhealth.restart.with.unhealthy.container which should be applied on containers which must be restarted after deunhealth restarts a monitored one. The value of the label should refer to a deunhealth monitored container.
Ex:
Container_1 has the label deunhealth.restart.on.unhealthy=true
Container_2 has the label deunhealth.restart.with.unhealthy.container=Container_1
When Container_1 gets unhealthy, deunhealth will restart it, and will restart Container_2 afterward:
2023-03-10T15:23:03-05:00 INFO Monitoring containers Container_1 to restart when becoming unhealthy
2023-03-10T15:23:03-05:00 INFO container Container_1 (image alpine:3.15) is unhealthy, restarting it...
2023-03-10T15:23:04-05:00 INFO container Container_1 restarted successfully
2023-03-10T15:23:04-05:00 INFO container Container_2 (image alpine:3.15) is linked to unhealthy container Container_1, restarting it...
2023-03-10T15:23:04-05:00 INFO linked container Container_2 restarted successfully
In some cases, I need to restart other containers after deunhealth restarts the one with the
deunhealth.restart.on.unhealthy
label.In order to do this, I added a new label
deunhealth.restart.with.unhealthy.container
which should be applied on containers which must be restarted after deunhealth restarts a monitored one. The value of the label should refer to a deunhealth monitored container.Ex:
Container_1 has the label
deunhealth.restart.on.unhealthy=true
Container_2 has the labeldeunhealth.restart.with.unhealthy.container=Container_1
When Container_1 gets unhealthy, deunhealth will restart it, and will restart Container_2 afterward: