Share via


從 IoT Edge 裝置上連線的登錄提取映像

若要從連線的登錄提取映像,請設定用戶端權杖,並傳遞權杖認證以存取登錄內容。

必要條件

建立範圍對應

使用 az acr scope-map create 命令來建立範圍對應,以獲得 hello-world 存放庫的讀取存取權:

# Use the REGISTRY_NAME variable in the following Azure CLI commands to identify the registry
REGISTRY_NAME=<container-registry-name>

az acr scope-map create \
  --name hello-world-scopemap \
  --registry $REGISTRY_NAME \
  --repository hello-world content/read \
  --description "Scope map for the connected registry."

建立用戶端權杖

使用 az acr token create 命令來建立用戶端權杖,並將它與新建立的範圍對應產生關聯:

az acr token create \
  --name myconnectedregistry-client-token \
  --registry $REGISTRY_NAME \
  --scope-map hello-world-scopemap

該命令會傳回新產生權杖的詳細資料,包括密碼。

重要

確定您儲存產生的密碼。 這些是一次性密碼,且無法擷取。 您可以使用 az acr token credential generate 命令來產生新的密碼。

使用用戶端權杖更新連線的登錄

使用 az acr connected-registry update 命令,以新建立的用戶端權杖更新連線的登錄。

az acr connected-registry update \
  --name $CONNECTED_REGISTRY_RW \
  --registry $REGISTRY_NAME \
  --add-client-token myconnectedregistry-client-token

從連線的登錄提取映像

從可存取 IoT Edge 裝置的電腦,使用下列範例命令,使用用戶端權杖認證登入連線的登錄。 如需管理登入認證的最佳作法,請參閱 docker login 命令參考。

警告

如果您將連線的登錄設定為不安全的登錄,請更新 Docker 精靈設定中不安全的登錄清單,以在 IoT Edge 裝置上包含連線的登錄的 IP 位址 (或 FQDN) 和連接埠。 此設定應僅用於測試目的。 如需詳細資訊,請參閱測試不安全的登錄

docker login --username myconnectedregistry-client-token \
  --password <token_password> <IP_address_or_FQDN_of_connected_registry>:<port>

針對 IoT Edge 案例,請務必包含用來連線到裝置上連線的登錄的連接埠。 範例:

docker login --username myconnectedregistry-client-token \
  --password xxxxxxxxxxx 192.0.2.13:8000

然後,使用下列命令來提取 hello-world 映像:

docker pull <IP_address_or_FQDN_of_connected_registry>:<port>/hello-world

下一步