ualex73 / monitor_docker

Monitor Docker containers from Home Assistant
Apache License 2.0
267 stars 34 forks source link

I'm constantly forced to restart HASS when any docker container is re-created on all monitored systems #143

Closed douginoz closed 1 month ago

douginoz commented 2 months ago

I know this is a duplicate of #124 and several others, but they were logged many months ago and longer, and it doesn't look like there's been any response yet. I'm trying to create dashboards to monitor multiple systems, and it all works fine until a docker container is re-created with something like watchtower. At that point it's ID changes and monitor_docker sees it as dead because the ID is no longer available. But since there's no way to reload it or tell it to refresh, all my monitoring eventually becomes useless because all containers eventually get renewed and thus monitor_docker sees them all as dead, when they're not.

I'm really hoping This can get sorted because it undermines the whole purpose of monitor_docker!

dziban303 commented 2 months ago

I wouldn't hold my breath, this integration seems dead. @ualex73 hasn't been around since December.

ualex73 commented 1 month ago

This still happens with the "master" version? Now tagged as v1.15.

ualex73 commented 1 month ago

I need to debug more, because I myself cannot reproduce this specific scenario TBC.

ualex73 commented 1 month ago

Can you try the latest version? I haven't tagged it as version, I will do that, when I get a confirmation.

douginoz commented 1 month ago

Will do. I'll need to wait for one of the services to have an updated version available since the problem occurs when watchtower updates it.
The normal process of me deleting a docker container manually and re-adding it doesn't trigger the problem, because the first step of removing the container also removes the entry in HA; so the subsequent addition of an updated docker container is seen as completely new to monitor_docker.
I believe the problem is that the watchtower process updates the container in a way that doesn't cause monitor_docker to treat it as gone/deleted. There may be some other way I could test this but I'm not all that familiar with it. I've tried simply deleting and re-creating the docker container, but as I said, monitor_docker simply sees that as 2 actions - removal of 'x' then creation of 'y'.

ualex73 commented 1 month ago

Docker can do basically 3 things:

The create and delete are straight forward, but with such update it does 3 actions. The actions are create (new container with temporary name), delete (delete the original container) and rename (change temporary name back to original).

The update part was tricky, so I made is super simple ;-) I made it a delete & create when this happens. So now it should behave fine is my expectation.

ualex73 commented 1 month ago

I will close this one, if it happens again, please raise a new issue.