Create a new build rule for DockerHub repository via API calls Create a new build rule for DockerHub repository via API calls docker docker

Create a new build rule for DockerHub repository via API calls


Docker Hub is following the git conventions where you wouldn't normally put different versions of the application in the same git commit. Instead, you would use separate branches and tags for different versions of your code. If you follow that git convention, then you can tag your resulting image based on the regex on the branch or tag. E.g.

  • Source Type: Branch
  • Source: /^v([0-9.]+)$/
  • Docker Tag: v{\1}

Then you can build within a branch called v1.1 (or any other version number) and the docker image will be tagged v1.1. To pull out just the first number of the tag, that would look like:

  • Source Type: Tag
  • Source: /^v([0-9]+)[0-9.]*$/
  • Docker Tag: v{\1}

Which would convert a tag with a version number like v10.1.2 into a docker tag of v10 (only numbers before the . are matched in the first part of the regex).

For more details on their build rules, see:https://docs.docker.com/docker-hub/builds/#set-up-build-rules

Regarding the API, while the registry itself has a documented API, I'm not aware of a similar API for Docker Hub's administrative interface. You could try to capture the calls by sniffing the browser traffic and replicating it in your app, but Docker could modify those calls at any time since they don't support an API for that.