首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >generic::invalid_argument:无效构建:无效图像名“us.gcr.io/.无法解析引用:us.gcr.io/./

generic::invalid_argument:无效构建:无效图像名“us.gcr.io/.无法解析引用:us.gcr.io/./
EN

Stack Overflow用户
提问于 2021-06-21 12:30:08
回答 3查看 1.7K关注 0票数 3

当我推送到github时,我试图自动部署一个容器,我在GCP上启用了这个功能,但是它没有工作,当触发它时它会发出抱怨:

代码语言:javascript
复制
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(位于项目的根):

代码语言:javascript
复制
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构建提交生成
代码语言:javascript
复制
gcloud builds submit --tag gcr.io/cifar-clf/cifar-clf --project=cifar-clf
  • 部署容器
代码语言:javascript
复制
gcloud run deploy --image gcr.io/cifar-clf/cifar-clf --platform managed --project=cifar-clf --allow-unauthenticated

任何帮助或建议都将不胜感激,谢谢各位!

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2021-06-21 12:49:02

图像引用的命名组件只允许小写字符从分发的实现

代码语言:javascript
复制
// 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)))

所以你应该改变:

代码语言:javascript
复制
us.gcr.io/cifar-clf/CIFAR-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b

至:

代码语言:javascript
复制
us.gcr.io/cifar-clf/cifar-10_classification/cifar-clf:f2d5c55fad600b733fc5bcc84550fdd9a325b05b
票数 8
EN

Stack Overflow用户

发布于 2022-10-19 12:49:52

下面的方法将帮助您修复所面临的错误。

在使用Build触发器通过cloudbuild.yaml部署时,我也发生了同样的错误。

您可以使用变量$REPO_NAME覆盖您的reponame的值,如前面提到的这里

为了解决你和我一样的错误,

  • 编辑触发器
  • 添加变量REPO_NAME并使用cifar-10_classification重写回购名称

这归功于https://stackoverflow.com/users/596285/bmitch,因为我在做这个POC时偶然发现了bmitch的根本原因解释。

票数 3
EN

Stack Overflow用户

发布于 2022-11-03 18:27:55

如果您的回购名称包含大写字符,直接在云构建上使用$REPO_NAME作为工件注册库名称的一部分,则会由于工件注册组件的名称验证而引起问题。只有小写字符是可以接受的。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68067977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档