You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行gcloud builds submit遇404错误:/blobs/uploads路径未找到

Google Cloud Build推送镜像时404错误:请求URL未找到

执行命令gcloud builds submit --config docker-build.yml时触发404错误,错误信息显示解析HTTP响应体时发现无效字符'<',提示请求的URL /v2/<PROJECT>/<REPOSITORY>/<IMAGE>/blobs/uploads/在服务器上不存在。

完整错误输出

Creating temporary archive of 75 file(s) totalling 474.6 KiB before compression.
Uploading tarball of [.] to [gs://<PROJECT>_cloudbuild/source/1727423461.295631-b08f76f9724b4c95b7234a57fb6440da.tgz]
Created [https://cloudbuild.googleapis.com/v1/projects/<PROJECT>/locations/global/builds/5c040439-95cc-42b2-985e-c3baa7bb4562].
Logs are available at [ https://console.cloud.google.com/cloud-build/builds/5c040439-95cc-42b2-985e-c3baa7bb4562?project=156056269609 ].
Waiting for build to complete. Polling interval: 1 second(s).
---------------------------------- REMOTE BUILD OUTPUT -----------------------------------
starting build "5c040439-95cc-42b2-985e-c3baa7bb4562"

FETCHSOURCE
Fetching storage object: gs://<PROJECT>_cloudbuild/source/1727423461.295631-b08f76f9724b4c95b7234a57fb6440da.tgz#1727423463721043
Copying gs://<PROJECT>_cloudbuild/source/1727423461.295631-b08f76f9724b4c95b7234a57fb6440da.tgz#1727423463721043...
/ [1 files][140.2 KiB/140.2 KiB]                                                
Operation completed over 1 objects/140.2 KiB.
SETUPBUILD
BUILD
Already have image (with digest): gcr.io/cloud-builders/docker
Sending build context to Docker daemon  544.8kB
Step 1/11 : FROM python:3-slim
3-slim: Pulling from library/python
a2318d6c47ec: Already exists
e0175c87c1f4: Pulling fs layer
bea1d778e3e0: Pulling fs layer
7ce703381f53: Pulling fs layer
7ce703381f53: Verifying Checksum
7ce703381f53: Download complete
e0175c87c1f4: Verifying Checksum
e0175c87c1f4: Download complete
bea1d778e3e0: Verifying Checksum
bea1d778e3e0: Download complete
e0175c87c1f4: Pull complete
bea1d778e3e0: Pull complete
7ce703381f53: Pull complete
Digest: sha256:15bad989b293be1dd5eb26a87ecacadaee1559f98e29f02bf6d00c8d86129f39
Status: Downloaded newer image for python:3-slim
 ---> 0d8d642b665d
Step 2/11 : ENV PYTHONDONTWRITEBYTECODE=1
 ---> Running in 726520ca2762
Removing intermediate container 726520ca2762
 ---> 37395f7b9679
Step 3/11 : ENV PYTHONUNBUFFERED=1
 ---> Running in 0773f4d9bbe5
Removing intermediate container 0773f4d9bbe5
 ---> 6a88543b2f71
Step 4/11 : COPY shared_python-1.20.23-py3-none-any.whl .
 ---> 28d1f6ad0279
Step 5/11 : COPY requirements.txt .
 ---> 2204c82ae3fb
Step 6/11 : WORKDIR /app
 ---> Running in 2c6ce56f44fd
Removing intermediate container 2c6ce56f44fd
 ---> 8453deebdb48
Step 7/11 : COPY . /app
 ---> 900a09725435
Step 8/11 : RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
 ---> Running in be0c35de84cd
Adding user `appuser' ...
Adding new group `appuser' (5678) ...
Adding new user `appuser' (5678) with group `appuser (5678)' ...
Creating home directory `/home/appuser' ...
Copying files from `/etc/skel' ...
Adding new user `appuser' to supplemental / extra groups `users' ...
Adding user `appuser' to group `users' ...
Removing intermediate container be0c35de84cd
 ---> 9d8be7a7dce3
Step 9/11 : USER appuser
 ---> Running in dde09a1b0c8d
Removing intermediate container dde09a1b0c8d
 ---> 2725ea2a6ccf
Step 10/11 : EXPOSE 8080
 ---> Running in c8a1c1e0b5c8
Removing intermediate container c8a1c1e0b5c8
 ---> 5ad3b8e5c7fc
Step 11/11 : CMD ["gunicorn", "--bind", "0.0.0.0:8080",  "--timeout" "900", "main"]
 ---> Running in 7b005453ceeb
Removing intermediate container 7b005453ceeb
 ---> 30605e16b975
Successfully built 30605e16b975
Successfully tagged europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>:latest
PUSH
Pushing europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>
The push refers to repository [europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>]
bc7dff04434c: Preparing
060a2030295f: Preparing
50f1b4274077: Preparing
5eaa022b8a05: Preparing
d03c932f1afe: Preparing
5c5b1cd04947: Preparing
ecfc14c16318: Preparing
de732417db5d: Preparing
8e2ab394fabf: Preparing
5c5b1cd04947: Waiting
ecfc14c16318: Waiting
de732417db5d: Waiting
8e2ab394fabf: Waiting
error parsing HTTP 404 response body: invalid character '<' looking for beginning of value: "<!DOCTYPE html>\n<html lang=en>\n  <meta charset=utf-8>\n  <meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">\n  <title>Error 404 (Not Found)!!1</title>\n  
...
-label=Google></span></a>\n  <p><b>404.</b> <ins>That’s an error.</ins>\n  <p>The requested URL <code>/v2/<PROJECT>/<REPOSITORY>/<IMAGE>/blobs/uploads/</code> was not found on this server.  <ins>That’s all we know.</ins>\n"

相关配置文件

docker-build.yml

steps:
- name: 'gcr.io/cloud-builders/docker'
  script: |
    docker build . -t europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>:latest
  automapSubstitutions: false
images:
- 'europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>:latest'

docker-compose.yml

version: '3.4'

services:
  orderprocessinglinnworksapiproxy:
    image: europe-west2-b-docker.pkg.dev/<PROJECT>/<REPOSITORY>/<IMAGE>:latest
    build:
      context: .
      target: builder
      dockerfile: ./Dockerfile
    environment:
      - ERROR_LOG_DIR=${ERROR_LOG_DIR}
      - FLASK_APPLICATION_KEY=${FLASK_APPLICATION_KEY}
      - PYTHONPATH=$PYTHONPATH:/app:/app/
    
    # flask requires SIGINT to stop gracefully
    # (default stop signal from Compose is SIGTERM)
    stop_signal: SIGINT
    network_mode: host
    ports:
      - '8080:8080'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Dockerfile

# For more information, please refer to https://aka.ms/vscode-docker-python
FROM python:3-slim


# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1

# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1

# Install pip requirement

COPY shared_python-1.20.23-py3-none-any.whl .
COPY requirements.txt .
#RUN python -m pip install -r requirements.txt

WORKDIR /app
COPY /src /app

# Creates a non-root user with an explicit UID and adds permission to access the /app folder
# For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
USER appuser

EXPOSE 8080

# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["gunicorn", "--bind", "0.0.0.0:8080",  "--timeout" "900", "main"]

仓库创建及源码准备步骤

# 创建仓库
gcloud artifacts repositories create docker-repo --repository-format=docker --location=europe-west2

# 获取源码
pwd
git clone https://github.com/.../<SOLUTION>.git -b <BRANCH>
cd <SOLUTION>
rm -rf .git

解决方案

1. 修正镜像地址格式错误

错误的镜像地址包含多余的-b,正确的Artifact Registry Docker仓库地址格式为<region>-docker.pkg.dev/<project-id>/<repo-name>/<image-name>。将所有配置中的europe-west2-b-docker.pkg.dev替换为europe-west2-docker.pkg.dev,同时将<REPOSITORY>替换为实际创建的仓库名docker-repo。

修正后的docker-build.yml示例:

steps:
- name: 'gcr.io/cloud-builders/docker'
  script: |
    docker build . -t europe-west2-docker.pkg.dev/<PROJECT>/docker-repo/<IMAGE>:latest
  automapSubstitutions: false
images:
- 'europe-west2-docker.pkg.dev/<PROJECT>/docker-repo/<IMAGE>:latest'

2. 验证Cloud Build服务账号权限

确保Cloud Build服务账号(格式:<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com)拥有Artifact Registry Writer角色,或至少对目标仓库具备artifacts.repositories.uploadArtifacts权限。可通过以下命令添加角色:

gcloud projects add-iam-policy-binding <PROJECT> \
  --member="serviceAccount:<PROJECT_NUMBER>@cloudbuild.gserviceaccount.com" \
  --role="roles/artifactregistry.writer"

3. 重新执行构建命令

gcloud builds submit --config docker-build.yml

内容的提问来源于stack exchange,提问作者Dave Russell

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 20:23:09