deunhealth icon indicating copy to clipboard operation
deunhealth copied to clipboard

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

Open PiDroid-B opened this issue 2 years ago • 0 comments

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? 🧐

  • Add a solution to check childs when a restart of the parent is required and restart them when parent is "running" and/or "healthly".

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.

PiDroid-B avatar Jun 26 '22 10:06 PiDroid-B