简体   繁体   English

构建docker映像,使用内置映像ID标记,推送映像

[英]Build docker image, tag with built image id, push the image

Background: Running Kubernetes on Google Cloud. 背景:在Google Cloud上运行Kubernetes。

Because Kubernetes won't tolerate :latest tag for Rolling Updates, I'd find something like this useful. 因为Kubernetes不能忍受滚动更新的:latest标签,所以我会发现类似的东西很有用。

docker build . -t gcr.io/project/nginx:{built_image_id} && docker push gcr.io/project/nginx:{built_image_id}

I saw a blog post about using git commit hash as a tag. 我看到了一篇有关使用git commit hash作为标记的博客文章。 Any other alternatives to skip the "copy git hash step"? 还有其他选择可以跳过“复制git hash步骤”吗?

Thanks 😊 谢谢😊

According to Kubernetes documentations : 根据Kubernetes的文档

“ Doing a rolling update from image:latest to a new image:latest will fail, even if the image at that tag has changed. “从image:latest滚动更新到新的image:latest将失败,即使该标记处的图像已更改也是如此。 Moreover, the use of :latest is not recommended,” 此外,不建议使用:latest,”

They provided some best practices for configuration to help, that you can check in the following link and use as a guide. 他们提供了一些配置方面的最佳实践以提供帮助,您可以在以下链接中进行检查并用作指导。

From Denis's answer. 从丹尼斯的答案。 I got this, which should do the job. 我明白了,应该做的。

docker build . -t gcr.io/project/nginx:$(git rev-parse --short HEAD) && docker push gcr.io/project/nginx:$(git rev-parse --short HEAD)

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

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