Day26影片教学:Azure小白如何使用Azure Container Registry异地复写建立多份Container Image

在昨天我们谈完Azure小白如何使用Azure Container Instances执行Docker Container

,今天我们来介绍Azure Container Registry及Azure Container Registry异地复写

Azure Container Registry 简介

Azure Container Registry是managed Docker registry服务,以开放原始码

的Docker Registry 2.0为基础。,Container Registry是在 Azure中装载的

Private服务,可让您建置、储存和管理所有容器部署类型的映像。

我们可以在 Container Registry中使用 Docker CLI或Azure CLI来Push及

Puall Container Image,Azure Portal整合可让您以视觉化方式检查

https://ithelp.ithome.com.tw/upload/images/20201011/20112182M83fFlKMTn.jpg

Container Images in Container Registry,在分散式环境中Container

Registry异地复写功能可用来将container images散发至多个Azure资料中心,

以进行当地散发,除了储存container images,Azure Container Registry

Tasks 也可以在 Azure中建置container images,Tasks使用标准 Dockerfile

在Azure Container Registry中建立及储存container image,而不需要本机

Docker工具,透过 Azure Container Registry Tasks,DevOps程序和工具可以

用来进行随需建置,也可以用来将container image建完全自动化。

Deploy Azure Container Registry

使用 az acr create 命令来建立 Azure Container Registry

az acr create --resource-group learn-deploy-acr-rg --name $ACR_NAME --sku Premium

使用 Azure Container Registry Task建置container images

若你的公司使用container images来管理计compute workloads,你使用本机

Docker工具来建置container images,你现在可以使用 Azure Container

Registry Tasks 来建置这些containers,Container Registry Tasks也允许

DevOps process与source code commit的自动建置整合。

使用标准Dockerfile来提供建置指示,Azure Container Registry Tasks可让

你重复使用目前在环境中的任何Dockerfile,包括多阶段组建,以下为Docker

File内容范例:

FROM    node:9-alpine
ADD     https://raw.githubusercontent.com/Azure-Samples/acr-build-helloworld-node/master/package.json /
ADD     https://raw.githubusercontent.com/Azure-Samples/acr-build-helloworld-node/master/server.js /
RUN     npm install
EXPOSE  80
CMD     ["node", "server.js"]

从Azure Container Registry部署images

我们可以使用多种container management platforms(Azure Container

Instances, Azure Kubernetes Service,Docker for Windows or Mac)

从Azure Container Registry 提取Container Image。

https://ithelp.ithome.com.tw/upload/images/20201011/20112182MT1H2ut89V.jpg

Container registry authentication

Azure Container Registry不支援未经验证的存取,并且需要所有作业都经过

验证。 登录支援两种类型的身分识别:

-Azure Active Directory 身分识别:包括使用者和服务主体。 使用 Azure

Active Directory身分识别存取登录是以角色为基础,身分识别可以指派三个

角色其中之一:读者(仅限提取存取)、参与者(推送和提取存取权),或拥有者

(提取、推送并指派角色给其他使用者)。

-每个登录中包含管理帐户:预设会停用管理帐户。

以下为使用Azure CLI建立container指令,必需输入registry-username及

registry-password

az container create \
    --resource-group learn-deploy-acr-rg \
    --name acr-tasks \
    --image $ACR_NAME.azurecr.io/helloacrtasks:v1 \
    --registry-login-server $ACR_NAME.azurecr.io \
    --ip-address Public \
    --location <location> \
    --registry-username [username] \
    --registry-password [password]

将container image复写至不同的Azure区域

若你的公司有部署到数个区域的计算工作负载,藉此确保有本机项目来为分散的

客户群提供服务,你的目的是在每个有Image执行的区域放置container

registry,这项策略可实作网路近距作业,提供快速、可靠的Image Layer传输。

异地复写可让 Azure 容器登录作为单一登录,使用多重主要区域登录来服务数个

区域。

https://ithelp.ithome.com.tw/upload/images/20201011/20112182nLufmDapU0.jpg

geo-replicated registry(异地复写登录)能提供下列优点:

-可跨多个区域使用单一registry/image/tag名称

-从区域部署进行网路邻近registry存取

**-没有其他输出费用,因为Images是取自与container host相同区域中的local,

replicated registry**

-跨多个区域管理单一registry

az acr replication create --registry $ACR_NAME --location japaneast

https://ithelp.ithome.com.tw/upload/images/20201011/20112182mt2mE7U27A.png

手把手部署Azure Container Registry步骤:

https://docs.microsoft.com/zh-tw/learn/modules/build-and-store-container-images/2-deploy-azure-container-registry

手把手使用Azure Container Registry Task建置container image步骤:

https://docs.microsoft.com/zh-tw/learn/modules/build-and-store-container-images/3-build-container-image

手把手使用Azure Container Registry部署image步骤:

https://docs.microsoft.com/zh-tw/learn/modules/build-and-store-container-images/4-deploy-container-image

手把手将container image复写至不同的Azure区域步骤:

https://docs.microsoft.com/zh-tw/learn/modules/build-and-store-container-images/5-replicate-container-image

Day26教学讲义:

https://docs.microsoft.com/zh-tw/learn/modules/build-and-store-container-images/


<<:  DAY26 深度学习-卷积神经网路-Yolo V1

>>:  第 26 型 - 路由 (Router)

[Day1] Motivation

哈罗大家好,打ㄍㄟ厚,我是目前就读天大地大台科大的 Steven Meow,这是我第一次参加铁人赛,...

Day15:全端工程师的工作内容?(下)

一、前言   上一篇文章有提到我现职公司中全端工程师的工作项目大纲,这篇就我个人日常上班中比较常做、...

Genero Package 套件安装与更新方法

Genero 套件里如果在 server 上安装的,大多套件就是可执行档,以 -i 参数进行安装。...

Day29:复习 Channel、Flow

Coroutine 中如果要执行非同步程序,则需要把耗时任务写在 suspend 函式中,并且在一个...

[Angular] Day10. Property binding and Event binding

本篇中将介绍 Angular 的 property binding 与 event binding,...