Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to synchronize version control system revisions with Docker image versions?

What is a common, conventional pattern for associating Docker image versions in Docker registry and Git (for example) revisions? So user of repository will be able to switch at any revision and recreate environment that corresponds to that specific revision.

For example I have a repository with a project and integration server which automatically builds Docker images for every commit in repository. How these images can be tied to corresponding repository commits?

Using Docker you have two different repositories - with a project and with Docker images - so they must be synchronized, but what are recommended workflows for this?

like image 899
Gill Bates Avatar asked Sep 23 '14 05:09

Gill Bates


1 Answers

Docker Hub supports two types of repos, and you haven't said which kind you are using. In both cases, I would suggest you put the git revision or tag name in the version portion of the image name, e.g. "account/repo:version"

Manual Repository (docker push)

For manual builds, you should docker tag each version with the git revision. This is the recommended method because it gives you the most control and can be automated on your build system.

Automated Build Repository

For automated builds on the Docker Hub, you will need to manually create a new entry for each revision or tag you want built. This requires going to the Hub web UI and creating a new build configuration for your repo, as pictured below. There is no API at this time which allows you to change build settings on your repo, nor does the automated build system automatically add Docker Hub tags when you add tags to your Git Hub repo.

Note at this time (2014-10-07) there is a bug where the automated builds do not actually build from tags in your source code repository, they build from head of master branch. The status is shown on https://status.docker.com


Here is how to add a build configuration to an automated build:

enter image description here

like image 81
Andy Avatar answered Sep 23 '22 21:09

Andy