繁体   English   中英

Docker 映像的 Azure 私有注册表

[英]Azure private registry for docker image

下面是我的 yaml 文件,用于创建具有两个容器名称的容器组,即 fluentd 和 mapp。 但是对于 mapp 容器,我想从私有存储库中获取图像。 我没有使用 Azure Container Registry,我也没有使用它的经验。 我想将日志推送到 Loganalytics。

apiVersion: 2019-12-01
location: eastus2
name: mycontainergroup003
properties:
  containers:
  - name: mycontainer003
    properties:
      environmentVariables: []
      image: fluent/fluentd
      ports: []
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 1.5 
  - name: mapp-log 
    properties: 
    image: reg-dev.rx.com/gl/xg/iss/mapp/com.corp.mapp:1.0.0-SNAPSHOT_latest
    resources:
      requests: 
        cpu: 1 
        memoryInGb: 1.5 
    ports:  
    - port: 80  
    - port: 8080 
    command:  - /bin/sh - -c  - >  i=0;  while true;  do  echo "$i: $(date)" >> /var/log/1.log;  echo "$(date) INFO $i" >> /var/log/2.log;  i=$((i+1));  sleep 1;  done 
  imageRegistryCredentials: 
  - server: reg-dev.rx.com 
    username: <username> 
    password: <password> 
  osType: Linux 
  restartPolicy: Always 
  diagnostics: 
    logAnalytics: 
      workspaceId: <id> 
      workspaceKey: <key> 
tags: null 
type: Microsoft.ContainerInstance/containerGroups

我正在执行以下命令来运行 yaml:

>az container create -g rg-np-tp-ip01-deployt-docker-test --name mycontainergroup003  --file .\azure-deploy-aci-2.yaml
(InaccessibleImage) The image 'reg-dev.rx.com/gl/xg/iss/mapp/com.corp.mapp:1.0.0-SNAPSHOT_latest' in container group 'mycontainergroup003' is not accessible. Please check the image and registry credential.
Code: InaccessibleImage
Message: The image 'reg-dev.rx.com/gl/xg/iss/mapp/com.corp.mapp:1.0.0-SNAPSHOT_latest' in container 
group 'mycontainergroup003' is not accessible. Please check the image and registry credential.

如何使 imageregistry reg-dev.rx.com 可以从 Azure 访问。 到目前为止,我在每个 yaml 中都使用了相同的 imageregistry 并运行了“kubectl apply”命令。 但现在我正在尝试通过 Azure cli 运行 yaml。 有人可以帮忙吗?

当您为尝试提取的登录服务器或图像提供错误的名称和凭据时,通常会出现错误。

我无法测试您尝试使用的私有注册表。 但同样的事情可以通过 Azure Container registry 使用 achive。 我在我的环境中进行了测试,它对我来说工作正常,你也可以在你的环境中应用。

您可以使用以下命令将现有图像推送到 ACR

示例:您可以像下面这样申请

第 1 步:登录 azure

 az login

第 2 步:创建容器注册表

az acr create -g "<resource group>" -n "TestMyAcr90" --sku Basic --admin-enabled true

.

第 3 步:以以下格式标记 docker 映像loginserver/imagename

docker tag 0e901e68141f testmyacr90.azurecr.io/my_nginx
在此处输入图像描述

第四步:登录ACR

docker login testmyacr90.azurecr.io

第 5 步:将 docker 镜像推送到容器注册表中

docker push testmyacr90.azurecr.io/my_nginx

在此处输入图像描述

YAML 文件

apiVersion: 2019-12-01
location: eastus2
name: mycontainergroup003
properties:
  containers:
  - name: mycontainer003
    properties:
      environmentVariables: []
      image: fluent/fluentd
      ports: []
      resources:
        requests:
          cpu: 1.0
          memoryInGB: 1.5
  - name: mapp-log
    properties:
      image: testmyacr90.azurecr.io/my_nginx:latest
      resources:
        requests:
          cpu: 1
          memoryInGb: 1.5
      ports:
      - port: 80
      - port: 8080
      command:
        - /bin/sh
        - -c
        - >
          i=0;
          while true;
          do
            echo "$i: $(date)" >> /var/log/1.log;
            echo "$(date) INFO $i" >> /var/log/2.log;
            i=$((i+1));
            sleep 1;
          done
  imageRegistryCredentials:
  - server: testmyacr90.azurecr.io
    username: TestMyAcr90
    password: SJ9I6XXXXXXXXXXXZXVSgaH
  osType: Linux
  restartPolicy: Always
  diagnostics:
    logAnalytics:
      workspaceId: dc742888-fd4d-474c-b23c-b9b69de70e02
      workspaceKey: ezG6IXXXXX_XXXXXXXVMsFOosAoR+1zrCDp9ltA==
tags: null
type: Microsoft.ContainerInstance/containerGroups

您可以从这里获取 ACR 的登录服务器名称、用户名和密码。

在此处输入图像描述

成功运行文件并能够创建容器组以及文件中声明的两个容器。

在此处输入图像描述

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM