检查 Azure 容器注册表的运行状况Check the health of an Azure container registry

使用 Azure 容器注册表时,可能会偶尔遇到问题。When using an Azure container registry, you might occasionally encounter problems. 例如,由于本地环境中的 Docker 出现问题,可能无法拉取容器映像。For example, you might not be able to pull a container image because of an issue with Docker in your local environment. 或者,可能会因网络问题而无法连接到注册表。Or, a network issue might prevent you from connecting to the registry.

进行诊断时,首先请运行 az acr check-health 命令,了解环境的运行状况,并可选择访问目标注册表。As a first diagnostic step, run the az acr check-health command to get information about the health of the environment and optionally access to a target registry. 此命令可在 Azure CLI 2.0.67 或更高版本中使用。This command is available in Azure CLI version 2.0.67 or later. 如果需要进行安装或升级,请参阅安装 Azure CLIIf you need to install or upgrade, see Install Azure CLI.

运行 az acr check-healthRun az acr check-health

下述示例演示了如何通过不同方式运行 az acr check-health 命令。The follow examples show different ways to run the az acr check-health command.

仅检查环境Check the environment only

若要检查本地 Docker 守护程序、CLI 版本和 Helm 客户端配置,请在没有其他参数的情况下运行此命令:To check the local Docker daemon, CLI version, and Helm client configuration, run the command without additional parameters:

az acr check-health

检查环境和目标注册表Check the environment and a target registry

若要检查对注册表的访问权限并执行本地环境检查,请传递目标注册表的名称。To check access to a registry as well as perform local environment checks, pass the name of a target registry. 例如:For example:

az acr check-health --name myregistry

错误报告Error reporting

此命令将信息记录到标准输出。The command logs information to the standard output. 如果检测到问题,它会提供错误代码和说明。If a problem is detected, it provides an error code and description. 若要详细了解代码和可能的解决方案,请查看错误参考For more information about the codes and possible solutions, see the error reference.

默认情况下,该命令在发现错误时会停止。By default, the command stops whenever it finds an error. 也可运行此命令,这样它就会提供所有运行状况检查的输出,即使发现了错误。You can also run the command so that it provides output for all health checks, even if errors are found. 按以下示例中所示添加参数 --ignore-errorsAdd the --ignore-errors parameter, as shown in the following examples:

# Check environment only
az acr check-health --ignore-errors

# Check environment and target registry
az acr check-health --name myregistry --ignore-errors

示例输出:Sample output:

$ az acr check-health --name myregistry --ignore-errors --yes

Docker daemon status: available
Docker version: Docker version 18.09.2, build 6247962
Docker pull of 'mcr.microsoft.com/mcr/hello-world:latest' : OK
ACR CLI version: 2.2.9
Helm version:
Client: &version.Version{SemVer:"v2.14.1", GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
DNS lookup to myregistry.azurecr.cn at IP 40.xxx.xxx.162 : OK
Challenge endpoint https://myregistry.azurecr.cn/v2/ : OK
Fetch refresh token for registry 'myregistry.azurecr.cn' : OK
Fetch access token for registry 'myregistry.azurecr.cn' : OK

后续步骤Next steps

若要详细了解 az acr check-health 命令返回的错误代码,请参阅运行状况检查错误参考For details about error codes returned by the az acr check-health command, see the Health check error reference.

参阅常见问题解答,其中解答了有关 Azure 容器注册表的常见问题和其他已知问题。See the FAQ for frequently asked questions and other known issues about Azure Container Registry.