简体   繁体   English

谷歌云构建错误:构建步骤 0“gcr.io/cloud-builders/docker”失败:步骤以非零状态退出:1

[英]Google Cloud Build Error: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

Note: There is a similar post regarding this issue but it involves a CI/CD workflow and a considerably more complicated Dockerfile.注意:有一篇关于此问题的类似帖子,但它涉及 CI/CD 工作流程和相当复杂的 Dockerfile。 The solutions presented do not seem to apply to my situation.提出的解决方案似乎不适用于我的情况。

Per Google documentation I am attempting to build an image by running gcloud run deploy in the directory where the files mentioned in my Dockerfile are located.根据Google 文档,我试图通过在 Dockerfile 中提到的文件所在的目录中运行gcloud run deploy来构建映像。 The Dockerfile appears as: Dockerfile 显示为:

FROM python:3.9-alpine
WORKDIR /app
COPY main.py /app/main.py
COPY requirements.txt /tmp/requirements.txt
RUN pip3 install -r /tmp/requirements.txt
CMD ["python3", "main.py"]

I receive a message that the build failed, and when checking the logs I see the following:我收到一条构建失败的消息,在检查日志时,我看到以下内容:

starting build "..."

FETCHSOURCE
Fetching storage object: gs://my-app_cloudbuild/source/....
Copying gs://my-app_cloudbuild/source/...
/ [0 files][    0.0 B/  1.5 KiB]                                                
/ [1 files][  1.5 KiB/  1.5 KiB]                                                
Operation completed over 1 objects/1.5 KiB.                                      
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1

Can anyone explain the reason for this error?谁能解释这个错误的原因? I suspect it has to do with how files are copied to the image, but I was able to build and run this container without problem on my local machine.我怀疑这与文件如何复制到映像有关,但我能够在本地计算机上构建和运行这个容器而没有问题。 Any idea why this fails in Cloud Run Build?知道为什么这在 Cloud Run Build 中失败了吗?

Running ls -la in the directory where I ran gcloud run deploy returns:在我运行gcloud run deploy的目录中运行ls -la返回:

drwxr-xr-x   9 user  staff       288 May 20 16:04 .
drwxr-xr-x   6 user  staff       192 May 20 13:35 ..
drwxr-xr-x  14 user  staff       448 May 20 16:06 .git
-rw-r--r--   1 user  staff        27 May 20 15:06 .gitignore
-rw-r--r--   1 user  staff       424 May 20 16:54 Dockerfile
-rw-r--r--   1 user  staff      3041 May 20 15:55 main.py
-rw-r--r--   1 user  staff       144 May 19 09:42 requirements.txt
drwxr-xr-x   6 user  staff       192 May 19 09:09 venv

Contents of .gitignore : .gitignore的内容:

Dockerfile
venv
*.gz
*.tar
*.pem

Full console output when attempting two-step build (see comments):尝试两步构建时的完整控制台输出(见评论):

user@users-MacBook-Pro TwitterBotAQI % gcloud builds submit  --tag gcr.io/missoula-aqi/aqi
Creating temporary tarball archive of 2 file(s) totalling 3.1 KiB before compression.
Some files were not included in the source upload.

Check the gcloud log [/Users/user/.config/gcloud/logs/2022.05.20/18.40.53.921436.log] to see which files and the contents of the
default gcloudignore file used (see `$ gcloud topic gcloudignore` to learn
more).

Uploading tarball of [.] to [gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/missoula-aqi/locations/global/builds/0c22d976-171e-4e7b-92d8-ec91704d6d52].
Logs are available at [https://console.cloud.google.com/cloud-build/builds/0c22d976-171e-4e7b-92d8-ec91704d6d52?project=468471228522].
------------------------------------------------------------------------------------ REMOTE BUILD OUTPUT -------------------------------------------------------------------------------------
starting build "0c22d976-171e-4e7b-92d8-ec91704d6d52"

FETCHSOURCE
Fetching storage object: gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz#1653093655000531
Copying gs://missoula-aqi_cloudbuild/source/1653093653.998995-48d4ba15b3274455a21e16b7abc7d65b.tgz#1653093655000531...
/ [1 files][  1.5 KiB/  1.5 KiB]                                                
Operation completed over 1 objects/1.5 KiB.
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /workspace/Dockerfile: no such file or directory
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

BUILD FAILURE: Build step failure: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
ERROR: (gcloud.builds.submit) build 0c22d976-171e-4e7b-92d8-ec91704d6d52 completed with status "FAILURE"

I had added Dockerfile to .gitignore as it contained API keys stored as environment variables.我已将Dockerfile添加到.gitignore ,因为它包含存储为环境变量的 API 密钥。 Removing Dockerfile from .gitignore resolved the issue..gitignore中删除Dockerfile解决了这个问题。

暂无
暂无

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

相关问题 无法在 Google Cloud Build 本地找到图像“gcr.io/fullstackgcp/gradle:latest” - Unable to find image 'gcr.io/fullstackgcp/gradle:latest' locally on Google Cloud Build 如何使用 `gcloud config` 构建基于 `gcr.io/google.com/cloudsdktool/cloud-sdk` 的镜像 - How to use `gcloud config` to build an image based on `gcr.io/google.com/cloudsdktool/cloud-sdk` 如何使用 docker + Google Cloud Build 公开构建步骤结果 - How to expose build step results using docker + Google Cloud Build 在 Google Cloud Publish 上找不到 gcr.io/google-appengine/aspnetcore:3.1 的清单 - manifest for gcr.io/google-appengine/aspnetcore:3.1 not found on Google Cloud Publish Docker服务无法构建:返回非零代码1 - Docker service failed to build : return a non-zero code 1 Docker 构建:返回非零代码:1,测试失败时 - Docker build: returned a non-zero code: 1, when test is failed 我可以运行 Docker 容器以在另一个 Google Cloud Build 步骤中使用吗? - Can I run a Docker container to use in another Google Cloud Build step? 在 Google Cloud Build 上运行步骤时,如何指定 docker 标志? - How can you specify docker flags when a step is ran on Google Cloud Build? 在 Google Cloud Build 中运行自定义镜像构建步骤时,如何保存对 docker 容器的更改并将其导出为 docker 镜像? - How can I save changes to a docker container and export it as a docker image when running custom image build step in Google Cloud Build? docker 构建:返回非零代码:5 - docker build: Returned a non-zero code: 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM