简体   繁体   English

将 Gitlab 容器注册表迁移到 Azure 容器注册表

[英]Migrating Gitlab Container Registry To Azure Contaner Registry

I am trying to migrate Gitlab-ce Container Registry to Azure Container Registry: the command im using:我正在尝试将 Gitlab-ce 容器注册表迁移到 Azure 容器注册表:我使用的命令:

az acr import \
  --name acr name\
  --source gitlab/repo/repo/tag
  --username ****\
  --password *****

and it works.它有效。

what im trying to do now since there is no direct migration in the internet is to create a script to automate the migration process由于互联网上没有直接迁移,我现在要做的是创建一个脚本来自动化迁移过程

my idea is like this:我的想法是这样的:

# Get list of projects,repos and tags
repos = i couldn't find a command to list the repos
for project in project do: 
    repos = get all repos
    for repo in repos do: 
        tags = get all tags 
        az acr import \
        --name acr name\
        --source gitlab/$project/$repo/$tag
        --username ****\
        --password *****
    done
done

The Problem is i couldn't find any command to list project,repos or tags using gitlab command line is there another way to automate the migration if i couldn't find the commands??问题是我找不到使用 gitlab 命令行列出项目、存储库或标签的任何命令,如果我找不到命令,是否还有另一种方法可以自动迁移?

Please check if below commands can give an idea to work around:请检查以下命令是否可以提供解决方法:

Here we try to use the Azure CLI commands az acr repository list and az acr repository show-tags to include image tags in a loop.在这里,我们尝试使用 Azure CLI 命令az acr repository listaz acr repository show-tags在循环中包含图像标签。

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

also please check the Azure PowerShell equivalents as in Reference: Microsoft Docs and almost similar to Stack Overflow thread还请检查 Azure PowerShell 等效项,如参考: Microsoft Docs和几乎类似于Stack Overflow 线程

References:参考:

  1. Moving docker images from one container registry to another | 将 docker 映像从一个容器注册表移动到另一个 | by Paulo Gomes | 通过保罗戈麦斯 | Medium 中等的

  2. container-registry-import-images | 容器注册表导入图像 | Microsoft Docs 微软文档

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

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