Docker 错误:无效的参考格式:存储库名称必须小写 [英] Docker error: invalid reference format: repository name must be lowercase

查看:75
本文介绍了Docker 错误:无效的参考格式:存储库名称必须小写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的一个项目中遇到了这个 Docker 错误:

Ran into this Docker error with one of my projects:

无效的引用格式:存储库名称必须小写

产生这条通用消息的各种原因是什么?

What are the various causes for this generic message?

经过一番努力,我已经想通了,所以我将回答我自己的问题以便在此处记录它,因为在进行网络搜索时解决方案不会立即出现,而且因为此错误消息没有不描述 Docker 遇到的直接问题.

I already figured it out after some effort, so I'm going to answer my own question in order to document it here as the solution doesn't come up right away when doing a web search and also because this error message doesn't describe the direct problem Docker encounters.

推荐答案

一个参考"在 docker 中是一个指向图像的指针.它可能是图像名称、图像 ID、名称中包含注册服务器、使用 sha256 标记来固定图像,以及任何其他可用于指向要运行的图像的内容.

A "reference" in docker is a pointer to an image. It may be an image name, an image ID, include a registry server in the name, use a sha256 tag to pin the image, and anything else that can be used to point to the image you want to run.

invalid reference format 错误消息意味着 docker 无法将您提供的字符串转换为图像.这可能是一个无效的名称,或者它可能来自 docker run 命令行中较早的解析错误,如果这是您运行图像的方式.

The invalid reference format error message means docker cannot convert the string you've provided to an image. This may be an invalid name, or it may be from a parsing error earlier in the docker run command line if that's how you run the image.

如果名称本身无效,存储库名称必须为小写 表示您在注册表或存储库名称中使用大写字符,例如YourImageName:latest 应该是 yourimagename:latest.

If the name itself is invalid, the repository name must be lowercase means you use upper case characters in your registry or repository name, e.g. YourImageName:latest should be yourimagename:latest.

使用 docker run 命令行,这通常是由于没有引用带空格的参数、缺少参数值以及错误命令行顺序的结果.命令行排序为:

With the docker run command line, this is often the result in not quoting parameters with spaces, missing the value for an argument, and mistaking the order of the command line. The command line is ordered as:

docker ${args_to_docker} run ${args_to_run} image_ref ${cmd_to_exec}

将 args 传递给运行时最常见的错误是卷映射扩展了包含空格的路径名,而不是引用路径或转义空格.例如

The most common error in passing args to the run is a volume mapping expanding a path name that includes a space in it, and not quoting the path or escaping the space. E.g.

docker run -v $(pwd):/data image_ref

如果您位于 /home/user/Some Project Dir 目录中,则将在您的容器中定义一个匿名卷 /home/user/Some,并尝试使用命令 Dir:/data image_ref 运行 Project:latest.解决方法是引用参数:

Where if you're in the directory /home/user/Some Project Dir, that would define an anonymous volume /home/user/Some in your container, and try to run Project:latest with the command Dir:/data image_ref. And the fix is to quote the argument:

docker run -v "$(pwd):/data" image_ref

其他容易忽略引用的地方包括环境变量:

Other common places to miss quoting include environment variables:

docker run -e SOME_VAR=Value With Spaces image_ref

哪个 docker 会解释为尝试运行图像 With:latest 和命令 Spaces image_ref.同样,修复方法是引用环境参数:

which docker would interpret as trying to run the image With:latest and the command Spaces image_ref. Again, the fix is to quote the environment parameter:

docker run -e "SOME_VAR=Value With Spaces" image_ref

对于撰写文件,如果您扩展图像名称中的变量,则该变量可能无法正确扩展.所以如果你有:

With a compose file, if you expand a variable in the image name, that variable may not be expanding correctly. So if you have:

version: 2
services:
  app:
    image: ${your_image_name}

然后仔细检查 your_image_name 是否定义为全小写字符串.

Then double check that your_image_name is defined to an all lower case string.

这篇关于Docker 错误:无效的参考格式:存储库名称必须小写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆