The health check CMD works well - I can see the container status to change to unhealthy in the docker ps output. However, this does not trigger a restart of this computer. How do I get the container restarted?
I am actually using willfarrell/autoheal to achieve the same goal, however I am still running into trouble:
the request to engine API /containers/{id}/restart endpoint always results in:
The requested URL returned error: 500 Internal Server Error
note that this also only happens for unhealthy containers. I can restart any other healthy container this way just fine.
any ideas? API Version is 1.41.
edit: nevermind. turns out I have a more special usecase: the container in question is attached to its “parent container” via network_mode: service - as soon as parent container is recreated (not restarted, restarting works fine with autoheal), the container will become unhealthy, lose any network connections whatsoever (because network_mode prevents defining other networks) and thus the API cant reach the container anymore. I can’t switch to another network_mode, because the parent container is a vpn app where multiple “child” containers use it as a service to tunnel all their networking through it. From what I read on various topics there does not seem to be a solution to automate the restart of the depending containers if parent is recreated, sadly.