简体   繁体   English

默认情况下,Google Cloud Build 是否在步骤之间保留 docker 张图像?

[英]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.

相关问题 谷歌云构建构建步骤的“显示名称” - Google cloud build "display name" for build steps 默认情况下,Google Cloud Build 标签触发器是否适用于所有分支? - Does Google Cloud Build tag trigger apply to all branches by default? 为什么 Google Cloud Build 配置文件不使用 docker 构建步骤的入口点? - Why does the Google Cloud Build configuration file not use an entrypoint for docker build step(s)? Cloud Build 不会将我的 Docker 图像推送到带有 cloudbuild.yaml 图像字段的 Artifact Registry - Cloud Build does not push my Docker image to Artifact Registry with images field in cloudbuild.yaml 在云构建中执行各种步骤 - executing various steps in cloud build 在谷歌云构建中的两个容器之间进行通信 - Communicate between two containers in Google cloud build Google Cloud Build Docker build-arg 不受尊重 - Google Cloud Build Docker build-arg not respected Google Cloud Artifact Registry Docker 具有虚拟大小的图像的存储定价 - Google Cloud Artifact Registry Docker Storage pricing for images with Virtual size 如何在谷歌云构建中将参数传递给 docker run - How to pass parameters to docker run in google cloud build Docker:构建 Debian 11 镜像,其中包含 Python 和 Google Cloud SDK - Docker: Build Debian 11 image, with Python and Google Cloud SDK in it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM