[英]Does Google Cloud Build keep docker images between steps by default?
Does Google Cloud Build keep docker images between build steps by default?默认情况下,Google Cloud Build 会在构建步骤之间保留 docker 个图像吗?
In their docs they say built images are discarded after every step but I've seen examples in which build steps use images produced in previous build ones, so?在他们的文档中,他们说构建的图像在每一步后都会被丢弃,但我已经看到构建步骤使用以前构建步骤中生成的图像的示例,所以? are built images discarded on completion of every step or saved somewhere for coming steps?
构建的图像是在完成每个步骤时丢弃还是保存在某个地方以供后续步骤使用?
Here's my cloudbuild.yaml
.这是我的
cloudbuild.yaml
。
steps:
- name: gcr.io/cloud-builders/docker
args:
- build
- '-t'
- '${_ARTIFACT_REPO}'
- .
- name: gcr.io/cloud-builders/docker
args:
- push
- '${_ARTIFACT_REPO}'
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
args:
- run
- deploy
- my-service
- '--image'
- '${_ARTIFACT_REPO}'
- '--region'
- us-central1
- '--allow-unauthenticated'
entrypoint: gcloud
Yes, Cloud Build keep images between steps.是的,Cloud Build 在步骤之间保留图像。
You can imagine Cloud Build like a simple VM or your local computer so when you build an image it is stored in local (like when you run docker build -t TAG.
)您可以将 Cloud Build 想象成一个简单的 VM 或您的本地计算机,因此当您构建一个映像时,它会存储在本地(就像您运行
docker build -t TAG.
)
All the steps run in the same instance so you can re-use built images in previous steps in other steps.所有步骤都在同一实例中运行,因此您可以在其他步骤中重复使用之前步骤中构建的图像。 Your sample steps do not show this but the following do:
您的示例步骤未显示此内容,但以下内容显示:
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- build
- -t
- MY_TAG
- .
- name: 'gcr.io/cloud-builders/docker'
args:
- run
- MY_TAG
- COMMAND
- ARG
As well use the previous built image as part of an step:也可以使用之前构建的图像作为步骤的一部分:
steps:
- name: 'gcr.io/cloud-builders/docker'
args:
- build
- -t
- MY_TAG
- .
- name: 'MY_TAG'
args:
- COMMAND
- ARG
All the images built are available in your workspace until the build is done (success or fail).在构建完成(成功或失败)之前,所有构建的图像都可以在您的工作区中使用。
PD The reason I asked where did you read that the images are discarded after every step is because I've not read that in the docs unless I missed something, so if you have the link to that please share it with us. PD 我问你在哪里读到图像在每一步后都被丢弃的原因是因为我没有在文档中读到它,除非我错过了什么,所以如果你有链接,请与我们分享。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.