qdm12 / deunhealth

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

Feature request: auto-restart containers depend on restart unhealthly parent #49

Open PiDroid-B opened 2 years ago

PiDroid-B commented 2 years ago

context

When we have containers (aka childs) depending on another container (parent), the childs doesn't restart when the parent is failing and restarts.

services:
  parent_container:
      labels:
      - deunhealth.restart.on.unhealthy=true
     [...]

  child1:
    depends_on:
      parent_container:
        condition: service_healthy
      network_mode: "service:parent_container"
      labels:
      - deunhealth.restart.on.unhealthy=true    
     [...]        

  child2:
    depends_on:
      parent_container:
        condition: service_healthy
      network_mode: "service:parent_container"
      labels:
      - deunhealth.restart.on.unhealthy=true
     [...]        

What's the feature? 🧐

Suggested solution

Maybe something like that :

add a label for child : deunhealth.restart.on.depends_on=true (maybe change "true" to the parent's container_name)

workflow of auto-restart parent :
     -  restart the container (parent)
     -  get list of other containers contains the according label (childs)
              - if state is not running/healthly then restart it

Thank's for your help.