Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Webhook handler for dockerhub autodeployments

Project description

PyPi version Travis CI Status Coveralls Coverage Code Climate Rating Check

dockerhub-webhook listens to HTTP POST requests from dockerhub and triggers your scripts to update when a new container is available.


  • Python 3.3+ support.
  • Pip installion availble
  • Lightweight - built using Flask.
  • Supports unlimited number of triggers.
  • Full logging support including script errors.

Installation (Option 1: from Git)

Dockerhub-webhook is supported on python 3.3, 3.4, 3.5, and 3.6. To install from the github repository, the first step is to clone it.

git clone

Then install dependencies.

pip install -r requirements.txt

Next we need to create the config file which contains our apikey, maps scripts to incoming repository hooks. We can start from the example and filling in the variables listed.


To generate an apikey you can use tools such as openssl or pwgen.

openssl rand -base64 30 | sed 's=/=\\/=g'
pwgen 30 1

Alternatively you can set the $DOCKERHOOK_TOKEN environment variable with your key. This will override anything in

The HOOKS dict in maps respository names to serverside deploy scripts. Keys are the names of repositories (no namespace), and values are the full path to the script to be called, or a relative path to the current working directory.

HOOKS = {'repo1': '/full/path/to/',
         'repo2': ''

WSGI server (ex Gunicorn)

It is highly recommened you install a production ready WSGI server and not use the server packaged with Flask (Werkzeug) because it’s geared towards development. Here’s a quick example of how to start the application with Gunicorn. Gunicorn is typically reversed proxied by nginx.

NOTE: dockerhub-webhook looks for in the current working directory.

pip install gunicorn
gunicorn dockerhook:app -w 1 -b <host_ip>:<port>

Installation (Option 2: pip)

The biggest devation from installing from github is the directory stucture where the config file, logs, and optionally scripts needs to be created

mkdir -p dockerhook/log
mkdir -p dockerhook/scripts

You create your config file just as above, but instead of coming with the source, you have to download the example directly.

cd dockerhook
wget -o

Install using pip

pip install dockerhub-webhook

Configure Docker Hub

  1. Go to
  2. Click the repository you wish to autodeploy
  3. Under the Webhooks tab add a webhook
  4. Choose any name you please
  5. For the Webhook URL use the following:

Adjust the domain and endpoint to your reverse proxy setting, and replace secret with your API key.


dockerhub-webhook source code is provided under the Apachi 2.0 License.

  • Copyright (c), 2017, PrasieBeToScience.


Webhook uses github-flow for managing branches and follows PEP8 as much as possible.

To start Flask’s development Werkzeug server you can use

You can run pytest unittests using python test.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dockerhub-webhook, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size dockerhub_webhook-0.2.1-py3-none-any.whl (9.7 kB) File type Wheel Python version 3.5 Upload date Hashes View
Filename, size dockerhub-webhook-0.2.1.tar.gz (6.8 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page