简体   繁体   English

如何将版本控制系统修订与Docker映像版本同步?

[英]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? 在Docker注册表和Git(例如)修订版中关联Docker映像版本的常见常规模式是什么? 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. 例如,我有一个带有项目和集成服务器的存储库,该服务器会为存储库中的每个提交自动构建Docker映像。 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? 使用Docker时,您有两个不同的存储库-一个项目和Docker映像-因此必须同步,但是为此推荐的工作流程是什么?

Docker Hub supports two types of repos, and you haven't said which kind you are using. Docker Hub支持两种类型的存储库,您还没有说过使用哪种存储库。 In both cases, I would suggest you put the git revision or tag name in the version portion of the image name, eg "account/repo: version " 在这两种情况下,我建议您将git版本或标记名称放在映像名称的版本部分中,例如“ account / repo: version

Manual Repository ( docker push ) 手动存储库( docker push

For manual builds, you should docker tag each version with the git revision. 对于手动构建,您应使用git版本在docker tag每个版本。 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. 对于在Docker Hub上的自动构建,您将需要为要构建的每个修订或标签手动创建一个新条目。 This requires going to the Hub web UI and creating a new build configuration for your repo, as pictured below. 这需要转到Hub Web UI并为您的仓库创建一个新的构建配置,如下图所示。 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. 目前没有可用的API允许您更改存储库上的构建设置,当您将标签添加到Git Hub存储库时,自动构建系统也不会自动添加Docker Hub标签。

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. 请注意 ,此时(2014-10-07)存在一个错误,即自动构建实际上不是从源代码存储库中的标记构建的,而是从master分支的头构建的。 The status is shown on https://status.docker.com 状态显示在https://status.docker.com上


Here is how to add a build configuration to an automated build: 以下是将构建配置添加到自动构建的方法:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM