ualex73 / monitor_docker

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

[Feature Request] Recreate container #8

Closed firstof9 closed 4 years ago

firstof9 commented 4 years ago

I would love to see a service added to this to allow containers to pull the latest image, then recreate the container based on the Json data under Config from the docker API.

ualex73 commented 4 years ago

I think you basically like to create a container via monitor_docker. Technically the aiodocker library I use, should this. Only it will become a bit complex (I can't really validate if the input is "good" enough), so I need to think about it if it is really a useful service to add.

firstof9 commented 4 years ago

Fair enough, you really wouldn't need to validate the input since it would be coming from an already created container. Only validation needed would be to make sure the container name existed to pull the config from.

ualex73 commented 4 years ago

I will check if the underlying aiodocker library can do this (re-using the old settings), but it looks more a task for watchtower?

firstof9 commented 4 years ago

I maybe a single use case, but I would like to be able to hit "Upgrade Home Assistant" button from my UI and have it recreate the container with the latest image without having to use a command_line switch and bash script.

If you can't swing it no worries. It was just an idea.

ualex73 commented 4 years ago

aiodocker doesn't support the required rename feature, I will try to make a PR for that one first (and see if they accept it).

colemamd commented 4 years ago

+1 for this. I'm not familiar with the Docker API, but is it possible for this to read an existing compose file?

ualex73 commented 4 years ago

@colemamd Sorry, it isn't that easy to re-create a container. Neither doing it via docker-compose, you could make a shell command in HA to trigger docker-compose?

ualex73 commented 4 years ago

@firstof9 I have looked deeper in the Docker API and aiodocker, but it is not easy to do such re-creation (there is no 1:1 possible, because the names and datatypes are all different). If you are willing to make a PR yourself, I happy to merge it.

colemamd commented 4 years ago

Thanks for looking into it!