0

我正在按照此页面上的说明在 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 吗?

4

2 回答 2

1

可能是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' 
于 2020-08-17T02:16:12.583 回答
1

问题是我在计算机上的 Ubuntu WSL 安装中运行旧版本的 Azure CLI。当我尝试从安装了 2.9.1 版 Azure CLI 的 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>
于 2020-08-17T19:57:24.157 回答