Watchtower: Trigger container restart via WebHook

Created on 31 Dec 2015  路  6Comments  路  Source: containrrr/watchtower

Hi, instead of checking for the changes every N seconds, it would be nice to trigger container's restart once new image has been pushed successfully to the docker hub etc. Any ideas how to implement this?

Most helpful comment

The solution from #262 makes it possible to trigger via an additional service, but I wish this could be re-opened to potentially have an integrated solution in the future.

All 6 comments

I would also like this to happen. Polling is generally bad practice. Plus it now shows that I have over 2K pulls of my own image, which isn't very useful data.

Well, Docker Hub has a Webhooks tab, so if the watchtower container could expose a public http endpoint you could configure docker hub to ping it... but that would only help for repositories that you control. At least it could be an option...

Another idea: I guess currently watchtower just executes a local docker pull (regardless if it's via cli or daemon api)? So how about using this API on the registry directly: https://docs.docker.com/v1.6/registry/spec/api/#pulling-an-image-manifest (or the v1 https://docs.docker.com/v1.6/reference/api/registry_api/#get-image-layer_1)? Do hitting those increment the number of pulls Hub shows?

I am only interested in the images I control, because those are the ones I am developing, and I would like to have a workflow that pushing to master deploys to production.
And yes my dockerhub project having 10k pulls even though no one knows or cares about the project seems evident. But that's the smaller issue.
Currently it takes about 5 minutes per project to be built automatically on Dockerhub, so with the 5 minute polling I have set up with watchtower, each push to master can take potentially up to 10 minutes to get deployed when that time could be halved with webhooks.

I found that watchtower didn't really fit my needs for this use case so I ended up using a python web hook + an ansible playbook that pulls and updates containers from dockerhub.

https://github.com/stackdump/docker-ansible-webhook

_EDIT_ my only issue was that watchtower pulls incremented the counter on dockerhub ( really just a personal hangup )

This issue is very closely related to #262 and will as a result be closed.

The solution from #262 makes it possible to trigger via an additional service, but I wish this could be re-opened to potentially have an integrated solution in the future.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Fredrik81 picture Fredrik81  路  5Comments

simskij picture simskij  路  5Comments

dsteinkopf picture dsteinkopf  路  5Comments

eloo picture eloo  路  5Comments

auanasgheps picture auanasgheps  路  6Comments