Docker Hub Automated Build - Tagging

前端 未结 7 1712
逝去的感伤
逝去的感伤 2020-12-24 01:15

When specifying an Automated Build on Docker Hub, I can set some settings (Type (\'Branch\' or \'Tag\'), Name, Dockerfile Location and

相关标签:
7条回答
  • 2020-12-24 01:53

    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:

    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!

    0 讨论(0)
  • 2020-12-24 01:55

    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.

    0 讨论(0)
  • 2020-12-24 01:55

    I haven't used this feature yet so I can be wrong, but today when I went to the build settings tab and selected tag for the second type of build, it automatically had the regex /.*/ which will select all tags.

    I'll update this as soon as I test it.

    0 讨论(0)
  • 2020-12-24 01:59

    Usman answered with a workaround for a similar question in https://stackoverflow.com/a/26107743/155689

    Basically

    • go into the automated build settings,
    • add another build type using tag
    • enter a git tag name
    • and give it a version name
    • click save and trigger build

    As you can see I have done this for this automated build

    0 讨论(0)
  • 2020-12-24 01:59

    My solution to assign the tag "latest" to the latest build is to use the following configuration in the automated build:

    | Type   | Name   | Dockerfile Location | Tag Name |
    | Branch | master |        /            | latest   |
    

    Whenever there is a commit in master, a new build with tag "latest" is created.

    There was a problem a few days ago, where the automated build used the branch name as the tag name, so you might found a couple of builds with the "master". This is fixed: https://forums.docker.com/t/automated-builds-not-tagging-latest/683

    0 讨论(0)
  • 2020-12-24 02:02

    A few months ago I contacted docker support about explicitly providing version numbers and that was not supported at the time.

    What you specify on the docker hub is the git tag/branch that will be watched. The result of the build will always be tagged latest.

    0 讨论(0)
提交回复
热议问题