Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Hub Automated Build - Tagging

When specifying an Automated Build on Docker Hub, I can set some settings (Type ('Branch' or 'Tag'), Name, Dockerfile Location and Docker Tag Name). But unfortunately I didn't find any documentation for those.

I assume, that when I choose Type 'Branch' and enter a Name, this is the branch from my git repository on GitHub/BitBucket being used and that Docker Tag Name results in the tag being assigned to the created image.

I played around a bit with it and found some things that are not clear to me - but I hope you can explain to me.

  • adding more than one entry results in only one tag being assigned. I used 'Branch', 'master' and '/' and 'latest' as the Docker Tag Name in the first one, 'v1' in the second one. But only 'v1' is used as a tag.

  • Using Type 'Tag' didn't result in different result. I thought this might only build an image if a git commit is tagged with this value. What is this type for?

I was looking for the ability to assign the tag 'latest' to the latest build and use a scheme like v1, v2, v3 and so on for older builds as I could do when building images locally.

like image 952
MirkoMachine Avatar asked Aug 15 '14 14:08

MirkoMachine


People also ask

Is docker latest tag automatic?

The latest tag is applied by default to reference an image when you run Docker commands without specifying the tag value. The latest tag is applied to the most recent docker build or docker tag command that was run without a tag value explicitly set.

Does docker build automatically pull?

After pushing the image, the image is used as cache source on another machine. BuildKit automatically pulls the image from the registry if needed. On another machine: $ docker build --cache-from myname/myapp .

What are Docker Hub tags?

Docker tags are mutable named references to Docker images, much like branch refs in Git. They make it easy to pull and run images, and for image authors to roll out updates automatically. For example, to pull the latest Debian GNU/Linux image for the buster release: $ docker pull debian:buster.


1 Answers

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!

like image 107
Anton Drukh Avatar answered Oct 01 '22 05:10

Anton Drukh