Basically have watchtower monitor and update containers whenever new images are released. I’ve recently noticed that with searxng (using redis as db), hosted through nginx proxy manager, will have a steady downtime of about 15mins post update then come back online.
This is extremely frequent for searxng’s case as I have watchtower run every day and my preferred way of running most of my containers is with the latest tag. The way out of this downtime in my experience is a restart of NPM which brings back the searxng service.
I’m looking for a way to automate a restart of the NPM container after a successful update of searxng’s container.
I have checked the docs for watchtower, and the lifecycle hooks (a way to run sh scripts pre/post update) are able to run only from the applied container and not from the host system.
docker run --restart=unless-stopped URContainer ?? ArgoCd?
deleted by creator
Either use depends_on or think of a health check and use Will Farrell’s simple Docker Autoheal container that restarts containers when they become unhealthy. https://github.com/willfarrell/docker-autoheal
Doesn’t seem like this will do what I want.
This will do exactly what you want: You have to configure a healthcheck for searnxg that detects when it’s down. Maybe something with curl or whatever.
As soon as it’s down autoheal will restart the container. Doesn’t matter why it is down (update, dependency not running, …) autoheal will just restart the container.
I want to restart the NPM container (when the searxng service goes down) instead of searxng.
Ahhhh… alright, I misunderstood. So either depends_on is your friend or you could implement a rather dirty solution: Write a little script for the NPM healthcheck that also checks if searxng is online. Then use autoheal.
But that would be my last solution and only if the searxng is very closely depending on the npm container.
No worries. I ended up writing a systemd service that restarts the npm container a minute after the watchtower runs. I don’t know why I didn’t think of that earlier but I guess it’s a much simpler solution than using
depends_on
with npm which hosts a lot of my other services.
Not sure if this will work in your use case but I use OliveTin for automating docket commands. Link here https://github.com/OliveTin/OliveTin
Doesn’t. Not automated.