az acr run: error: unrecognized argument: --cmd

az acr run: error: unrecognized argument: --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 运行 命令似乎不支持文档中指定的 --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>