az acr运行:错误:无法识别的参数:--cmd

问题描述

我正在按照this page上的说明在Azure容器注册表中创建Docker映像。一切正常,直到进入“运行图像”步骤。当我运行命令时:

az acr run --registry {the name of my registry} --cmd '{the name of my registry}.azurecr.io/sample/hello-world:v1" /dev/null

我收到以下错误

az acr run: error: unrecognized argument: --cmd {the name of my registry}.azurecr.io/sample/hello-world:v1
usage: az acr run [-h] [--verbose] [--debug]
                  [--output {json,jsonc,table,tsv,yaml,none}]
                  [--query JMESPATH] --registry REGISTRY_NAME [--file FILE]
                  [--values VALUES] [--set SET_VALUE]
                  [--set-secret SET_SECRET] [--no-format] [--no-logs]
                  [--timeout TIMEOUT] [--resource-group RESOURCE_GROUP_NAME]
                  [--os OS_TYPE] [--platform PLATFORM]
                  [--auth-mode {None,Default}] [--no-wait]
                  [--subscription _SUBSCRIPTION]
                  <SOURCE_LOCATION>

az acr run命令似乎不支持文档中指定的--cmd参数。

当我运行az --version时,我得到以下信息:

azure-cli                         2.0.61 *
acr                                2.2.3 *

我在做什么错?文档是否正确?我应该使用其他版本的Azure CLI吗?

解决方法

cmd命令的末尾可能有一个错字,其中没有双引号("

 --cmd '{the name of my registry}.azurecr.io/sample/hello-world:v1"

请将其更改为单引号。

 --cmd '{the name of my registry}.azurecr.io/sample/hello-world:v1' 
,

问题是我在计算机的Ubuntu WSL安装中正在运行旧版本的Azure CLI。当我从安装了Azure CLI 2.9.1版本的Azure Cloud Shell中尝试命令时,该命令成功。此外,如果我获得了该命令的帮助,则会得到以下内容,其中包括--cmd参数。

usage: az acr run [-h] [--verbose] [--debug] [--only-show-errors]
                  [--output {json,jsonc,yaml,yamlc,table,tsv,none}]
                  [--query JMESPATH] [--subscription _SUBSCRIPTION] --registry
                  REGISTRY_NAME [--agent-pool AGENT_POOL_NAME] [--file FILE]
                  [--values VALUES] [--set SET_VALUE]
                  [--set-secret SET_SECRET] [--cmd CMD_VALUE] [--no-format]
                  [--no-logs] [--timeout TIMEOUT]
                  [--resource-group RESOURCE_GROUP_NAME] [--platform PLATFORM]
                  [--auth-mode {None,Default}] [--no-wait]
                  <SOURCE_LOCATION>

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...