Service webhooks in portainer

Portainer recently added webhooks you can use to automatically update running services. This is very useful to completely automate build processes when paired with docker cloud. This feature is available since v1.19.2.

Using webhooks on portainer is really simple, lets have a look at how it works.

When creating/adding a new service all you have to do is switch Create a service webhook on. Portainer will create the webhook and show the url on the Service details page after it’s created.

You can also enable or disable webhooks for existing services. First we need to go to the Service Details page of a service. Then we can find the Service webhook button at the top of this page in the Service details block. All you have to do to activate the webhook for this service is to toggle this switch, and your webhook url will show up to the right. If you enabled the webhook when creating the service the url will already be here.

The webhook toggle switch

The webhook url

Now all you need to do to trigger the update is to send a POST request to this url and portainer will update the service on it’s own.

If you want your services to get updated whenever you push a new image to docker hub you can set this up by creating a new webhook on the webhooks tab of your repository settings and entering the portainer webhook url here. If you’ve also set up automated builds on docker cloud your services on portainer will be updated simply by pushing your changes to git.

Adding the webhook url to a repository on docker hub

You can find the pull request on github here and the feature request issue here. Additional detailed information can be found here.