Docker Hub – Build Hooks

I tried out the Docker Hub post_push hook script today with my automated build and it works great.  This link has all the details around more advanced Docker Hub build scripting.

What I tried using the post_push script for was to tag my mainline build (latest) with another specific tag (release).

Steps to implement:

  1. Create a hooks folder in my GitHub repo.
  2. Create a script called “post_push” under the hooks folder that will tag the latest image with my release number.

    set -e
    tagStart=$(expr index “$IMAGE_NAME” 🙂
    docker tag $IMAGE_NAME ${repoName}:18.3.1
    docker push ${repoName}:18.3.1

The end results is the following:


So a possible use-case would be to have a Jenkins job that gets triggered when your Dockerfile changes in GitHub and updates the release version in the “post_push” script, then triggers the Docker Hub job.