Mohamed Elyakoubi
Mohamed Elyakoubi

Reputation: 13

Migrate Gitlab registry To Azure Container Registry

I want to move my Gitlab Registry to Azure Container registry

I found this command to Import from a non-Azure private container registry but it's for a single image not the whole registry

az acr import \
  --name myregistry \
  --source docker.io/sourcerepo/sourceimage:tag \
  --image sourceimage:tag \
  --username <username> \
  --password <password>

Is there a way to move all registry images at once ?

Upvotes: 0

Views: 758

Answers (1)

kavya Saraboju
kavya Saraboju

Reputation: 10871

Please check if below commands can give an idea to work around:

Here try to use the Azure CLI commands az acr repository list and az acr repository show-tags to include image tags in a loop.

( we can initiate Login at the start )

SOURCE_REGISTRY=myregistry
TARGET_REGISTRY=targetregistry

# Get list of source repositories
REPOS =  $(az acr repository list \  --name $SOURCE_REGISTRY --output tsv)

# Enumerate tags and import to target registry
for repo in $REPOS; do
    TAGS= $(az acr repository show-tags --name $OURCE_REGISTRY  --repository $repo --output tsv);

    for tag in $TAGS; do
        echo "Importing $repo:$tag";
        az acr import --name $TARGET_REGISTRY --source $SOURCE_REGISTRY /$repo":"$tag  --username <username>   --password <password>  ;
    done
done

or Azure PowerShell equivalents as in Reference: Microsoft Docs and almost similar to Stack Overflow thread

References:

  1. Moving docker images from one container registry to another | by Paulo Gomes | Medium
  2. container-registry-import-images | Microsoft Docs

Upvotes: 1

Related Questions