Azure ACR 이미지 마이그레이션 가이드
1. 개요
- Azure Container Registry(ACR)는 컨테이너 이미지를 안전하게 저장하고 관리할 수 있는 Azure의 프라이빗 Docker 레지스트리입니다
- 두 개의 ACR 간 이미지 마이그레이션(Azure ACR to ACR) 방법을 소개합니다. 이는 조직 간 협업, 환경 분리, 멀티 테넌트 전략 또는 리전 간 이중화 등에 활용됩니다.
2. 마이그레이션 시나리오
- 조직 A → 조직 B 로 이미지 이전
- 리전 A → 리전 B 로 복제 (DR 목적)
3. Mig 방법
3.1. 주의사항
| 항목 |
설명 |
| SKU 제한 |
Basic SKU는 익명 pull이 불가능하므로 타 ACR에서 import 실패 |
| RBAC 권한 |
cross-tenant 환경에서는 서비스 주체 또는 federated identity 사용 필수 |
| 네트워크 제한 |
Private Endpoint 설정된 ACR 간에는 import 제한 발생 가능 |
| 과금 |
import 작업 자체는 별도 과금 없으나, 저장소 및 데이터 전송 요금 주의 |
3.2. Docker를 이용한 A 테넌트 to B 테넌트 Pull Push 방법
- A ACR Name : acrfromatest
- B ACR Name : acrtobtest
- RepositoryName : testimage
# 이미지 확인
% docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
## -- A 테넌트 작업
# A 테넌트 로그인
% az login --tenant {A 계정 tenant ID} # --use-device-code
# 컨테이너 로그인
% az acr login --name acrfromatest
Login Succeeded
## -- 로컬 작업
# 로컬 이미지 pull
% docker pull acrfromatest.azurecr.io/testimage:v1
v1: Pulling from testimage
Digest: sha256:1098098091828
Status: Downloaded newer image for acrfromatest.azurecr.io/testimage:v1
acrfromatest.azurecr.io/testimage:v1
# pull 된 이미지 확인
% docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
acrfromatest.azurecr.io/testimage v1 0343271d2c94 2 weeks ago 13.3MB
# 이미지 tag 변경
% docker tag acrfromatest.azurecr.io/testimage:v1 acrtobtest.azurecr.io/testimage:latest
# 이미지 확인
% docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
acrfromatest.azurecr.io/testimage v1 0343271d2c94 2 weeks ago 13.3MB
acrtobtest.azurecr.io/testimage latest 0343271d2c94 2 weeks ago 13.3MB
## --B 테넌트 작업
# B 테넌트 로그인
% az login --tenant {B 계정 tenant ID }
# 컨테이너 로그인
% az acr login --name acrtobtest
Login Succeeded
# B ACR 에 push
% docker push acrtobtest.azurecr.io/testimage:latest
The push refers to repository [acrtobtest.azurecr.io/testimage]
6e174226ea69: Pushed
latest: digest: sha256:1231231 size: 480
i Info → Not all multiplatform-content is present and only the available single-platform image was pushed ## -- 멀티플랫폼(multi-platform) Docker 이미지를 푸시(push)하려 할 때, 일부 플랫폼(예: linux/arm64, linux/amd64)에 대한 이미지가 누락되어 단일 플랫폼(single-platform) 이미지만 레지스트리에 업로드되었음을 의미
## 업로드 -- 멀티플랫폼 이미지 완전히 빌드하고 푸시
docker buildx build \
--platform linux/amd64,linux/arm64 \
--push \
-t acrtobtest.azurecr.io/testimage:latest \
.
# 이미지 마이그레이션 후 확인
az acr repository list --name <TargetACRName> --output table
az acr repository show-tags --name <TargetACRName> --repository <TargetRepository>
3.3. azcli 를 이용한 ACR to ACR
- A ACR Name : acrfromatest
- B ACR Name : acrtobtest
- RepositoryName : testimage
3.3.1. 익명 옵션 ( 보안 취약으로 권고 하지 않음 )
## -- A 테넌트 작업
# 익명 옵션 활성화 -- Basic 미직원 Standard 사용 가능
az acr update --name acrfromatest --anonymous-pull-enabled true
(BadRequest) Anonymous pull is not supported for SKU Managed_Basic. For more information on SKU tiers, please visit https://aka.ms/acr/tiers.
Code: BadRequest
Message: Anonymous pull is not supported for SKU Managed_Basic. For more information on SKU tiers, please visit https://aka.ms/acr/tiers.
# 업그레이드
az acr update --name acrfromatest --sku Standard
# 다운 가능하나 제약 사항 있음
az acr update --name acrfromatest --sku Basic
## -- B 테넌트 작업
# import
az acr import \
--name acrtobtest \
--source acrfromatest.azurecr.io/testimage:latest \
--image testimage:latest
# 이미지 마이그레이션 후 확인
az acr repository list --name <TargetACRName> --output table
az acr repository show-tags --name <TargetACRName> --repository <TargetRepository>
## -- A 테넌트 작업
# 비활성 -- 보안 때문에 비활성화 작업
az acr update --name acrfromatest --anonymous-pull-enabled false
3.3.2. Service Principal 권한 부여 후 작업
RBAC 권한 필요
- A ACR Name : acrfromatest
- B ACR Name : acrtobtest
- RepositoryName : testimage
## -- A 테넌트 작업
### Service Principal 권한 부여 옵션
az ad sp create-for-rbac --name acr-mig-sp --role AcrPull --scopes /subscriptions/<SOURCE_SUB_ID>/resourceGroups/<RG>/providers/Microsoft.ContainerRegistry/registries/acrfromatest
## -- B 테넌트 작업
az acr import \
--name <TargetACRName> \
--source <SourceRepositoryName>:<tag> \
--image <TargetRepositoryName>:<tag> \
--registry /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.ContainerRegistry/registries/<SourceACRName>