Docker Hub Automated Build - Tagging Docker Hub Automated Build - Tagging docker docker

Docker Hub Automated Build - Tagging


Automated docker image tagging is available on dockerhub! I fiddled with this recently and wanted to share my findings, jumping on this thread (hope it's ok!)

So I have a public GitHub repo with an automated build link on dockerhub. I want the :latest tag to be updated every time I push to the master branch. Also, I want :X, :X.Y and :X.Y.Z tags to be created for every release I create on GitHub (tagged as vX.Y.Z on GitHub).

Here is how the build settings config looks like to support this:dockerhub build settings

And in text so it's easier to copy-paste:

| Type   | Name                              | Dockerfile Location | Docker Tag Name ||--------|-----------------------------------|---------------------|-----------------|| Branch | master                            | /                   | latest          || Tag    | /^v([0-9]+)\.([0-9]+)\.([0-9]+)$/ | /                   | {\1}            || Tag    | /^v([0-9]+)\.([0-9]+)\.([0-9]+)$/ | /                   | {\1}.{\2}       || Tag    | /^v([0-9]+)\.([0-9]+)\.([0-9]+)$/ | /                   | {\1}.{\2}.{\3}  |

Hope this helps!


This is VERY EASY in 2 STEPS ...

STEP 1 - Click the Automated Build link

Automated build link

STEP 2 - Add multiple automated builds to the same docker repo (most people do not know you can add multiple automated builds) by clicking the BLUE PLUS BUTTON (see image below)

Adding multiple automated builds

In the example in the image above I am ...

  • adding a "latest" docker tag which maps to the github master branch
  • adding a "0.1.0" docker tag which maps to the github 0.1.0 tag

Note that the github tag must exist!

NOW when I click save and trigger build 2 builds are started, one for the latest tag and one for the 0.1.0 tag.

Simple when you know how :) Thought I'd provide a full answer here since this is poorly documented.


For the new Docker Hub Automated Build Anton Drukh's excellent answer can be achieved with a single rule

Source Type: Tag

Source: /^v([0-9.])\.([0-9.])\.([0-9.])$/

Docker Tag: release-{\1},release-{\1}.{\2},release-{\1}.{\2}.{\3},latest

Note that this is slightly different from Anton's answer as I am building latest from tag rather than master commit.