简体   繁体   English

最好的 Docker 标记策略是什么?

[英]What is the best Docker tagging strategy?

It is certain, that "latest" tag is not enough (ie if you want to rollback/debug).可以肯定的是,“最新”标签是不够的(即如果你想回滚/调试)。

What is the best docker tagging practice?最好的 docker 标记做法是什么? Is it better to tag it with build number or commit number?用构建号或提交号标记它更好吗? Or some other option?还是其他一些选择?

We don't use tagging for development environment, because we have pretty nice test coverage, but I suggest, you can easily tag container with your CI tool build number (Teamcity, Jenkins), something like 我们不对开发环境使用标记,因为我们有非常好的测试覆盖率,但我建议,您可以使用CI工具内部版本号(Teamcity,Jenkins)轻松标记容器,类似于

docker build -t {yourserviceName}:{JENKINS BUILD NUMBER} docker build -t {yourserviceName}:{JENKINS BUILD NUMBER}

However, production deployments - is a little bit different story. 然而,生产部署 - 是一个有点不同的故事。 We use two tags for that - previous and latest 我们使用两个标签 - 前一个最新的

1.Build production container on teh build server 1.在构建服务器上构建生产容器

2.Push it to shared repo 2.推送到共享回购

3.Pull to production server. 3.Pull到生产服务器。

The latest tag is always contained at shared repository. 最新标记始终包含在共享存储库中。 Before step 3, just re-tag existing running container to previous . 在步骤3之前,只需将现有运行容器重新标记为上一个

What's the benefit? 有什么好处?

If you have your latest container with critical failure, you just rollback to previous one. 如果您的最新容器出现严重故障,则只需回滚到一个容器即可。 It's extremely rare case, when you have to do a rapid rollback, let's say, 4 deployments back , so no need to maintain versions there 这是非常罕见的情况,当你必须快速回滚时,比方说, 4个部署回来 ,所以不需要在那里维护版本

I would say go with an older one cause they might look more stable.我会说 go 和旧的,因为它们看起来更稳定。 But you can refer to this: https://hub.docker.com/_/node/tags不过你可以参考这个: https://hub.docker.com/_/node/tags

To get an idea of which one is suitable for you.了解哪一个适合您。

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

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