ualex73 / monitor_docker

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

Container not available anymore #104

Closed derekoharrow closed 1 month ago

derekoharrow commented 2 years ago

I've restarted/recreated some containers due to issues I had with them (which I have to do fairly often for a small set of containers). After having done this I get lots of instances of the following in the log file. I'm guessing monitor_docker is trying to track containers by their container id but re-creating them means that they are now different containers.

2022-06-27 13:18:36 ERROR (Thread-4) [custom_components.monitor_docker.helpers] [Docker] transmission: Container not available anymore (3) (DockerError(404, 'No such container: 4ca29d2f5523de93fe73d8ebf13b1a3e2c5ac4131058a9c144934dbeb8c97adb'))
Traceback (most recent call last):
  File "/config/custom_components/monitor_docker/helpers.py", line 751, in _run
    await self._run_container_info()
  File "/config/custom_components/monitor_docker/helpers.py", line 794, in _run_container_info
    raw = await self._container.show()
  File "/usr/local/lib/python3.9/site-packages/aiodocker/containers.py", line 177, in show
    data = await self.docker._query_json(
  File "/usr/local/lib/python3.9/site-packages/aiodocker/docker.py", line 300, in _query_json
    async with self._query(
  File "/usr/local/lib/python3.9/site-packages/aiodocker/utils.py", line 309, in __aenter__
    resp = await self._coro
  File "/usr/local/lib/python3.9/site-packages/aiodocker/docker.py", line 275, in _do_query
    raise DockerError(response.status, json.loads(what.decode("utf8")))
aiodocker.exceptions.DockerError: DockerError(404, 'No such container: 4ca29d2f5523de93fe73d8ebf13b1a3e2c5ac4131058a9c144934dbeb8c97adb')

Restarting Home Assistant fixes the problem, but only until I have to recreate a container again.

attila123456 commented 1 year ago

Same here, most containers are updated automatically by watchtower, and the log just blows up afterwards with thousands of these errors.

ualex73 commented 1 year ago

@attila123456 The containers have a new name or the same name?

DcR-NL commented 1 year ago

@ualex73 Same issue here, and yes, they have the same name.

derekoharrow commented 1 year ago

@ualex73 I think it is something to do with the container ID.

When you stop and restart a container, my understanding is that it keeps the same ID.

However, when you re-create a container, such as after pulling a new image down, it get's a new container ID.

I think this is what it is complaining about - it says the container (based on ID) no longer exists. This is technically true, but it has been replaced with a new container ID, but using the same name.

derekoharrow commented 1 year ago

Any update or progress on this at all?

dapuzz commented 1 year ago

Is perhaps possible to reload the integration in order to refresh the containers list with current ID? Thanks

ualex73 commented 1 month ago

Can you test the latest version, I believe it is fixed in this one. If confirmed, I will make a new version.

ualex73 commented 1 month ago

I will close this old issue. If still persists, please open a new issue.