【问题标题】:generic::invalid_argument: invalid build: invalid image name "us.gcr.io/.../... could not parse reference: us.gcr.io/..../generic::invalid_argument:无效构建:无效图像名称“us.gcr.io/.../...无法解析参考:us.gcr.io/..../
【发布时间】:2021-09-05 03:04:51
【问题描述】:

我试图在推送到 github 时自动部署一个容器,我在 GCP 上启用了该功能,但它不起作用,并且在触发时它会抱怨:

generic::invalid_argument: invalid build: invalid image name "us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b": could not parse reference: us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b

Dockerfile(在项目的根目录中):

FROM python:3.8

ENV APP_HOME /app
WORKDIR $APP_HOME

COPY . ./

RUN pip install -r requirements.txt

EXPOSE 8080

CMD python app.py

但我得到了上面的错误。

对于序数部署,它可以正常工作:

  • 使用 Google Cloud Build 提交构建
gcloud builds submit --tag gcr.io/cifar-clf/cifar-clf --project=cifar-clf
  • 部署容器
gcloud run deploy --image gcr.io/cifar-clf/cifar-clf --platform managed --project=cifar-clf --allow-unauthenticated

任何帮助或建议将不胜感激,谢谢大家!

【问题讨论】:

    标签: docker google-cloud-platform containers


    【解决方案1】:

    图片引用的命名组件只允许小写字符from the distribution implementation:

    // alphaNumericRegexp defines the alpha numeric atom, typically a
    // component of names. This only allows lower case characters and digits.
    alphaNumericRegexp = match(`[a-z0-9]+`)
    
    // separatorRegexp defines the separators allowed to be embedded in name
    // components. This allow one period, one or two underscore and multiple
    // dashes. Repeated dashes and underscores are intentionally treated
    // differently. In order to support valid hostnames as name components,
    // supporting repeated dash was added. Additionally double underscore is
    // now allowed as a separator to loosen the restriction for previously
    // supported names.
    separatorRegexp = match(`(?:[._]|__|[-]*)`)
    
    // nameComponentRegexp restricts registry path component names to start
    // with at least one letter or number, with following parts able to be
    // separated by one period, one or two underscore and multiple dashes.
    nameComponentRegexp = expression(
        alphaNumericRegexp,
        optional(repeated(separatorRegexp, alphaNumericRegexp)))
    

    所以你应该改变:

    us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b
    

    到:

    us.gcr.io/cifar-clf/cifar-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b
    

    【讨论】:

    • 非常感谢,构建成功但没有被推送到 GCP(在线应用程序没有更改),我应该添加一些东西来配置它以在构建后推送吗?提前谢谢伙计!
    • @mhannani 我不熟悉基于 gcloud 的构建。在 docker 中,您将执行 docker push.
    猜你喜欢
    • 2022-07-29
    • 1970-01-01
    • 2021-11-24
    • 1970-01-01
    • 1970-01-01
    • 2018-08-06
    • 2010-11-16
    • 1970-01-01
    • 2011-05-11
    相关资源
    最近更新 更多