Intro Previously, our docker images were stored in Azure's Container Registry. Recently, we built our own docker registry. We want to synchronize the docker images previously saved in Azure's Container Registry to our own docker registry. Implementation ideas Our method is relatively simple and low-level, but it can basically meet the requirements. Our approach is
Later, I suddenly remembered that Alibaba Cloud seems to have an image synchronization tool, https://github.com/AliyunContainerService/image-syncer Docker-Registry API Docker registry has a set of specifications, you can refer to https://docs.docker.com/registry/spec/api/ for more information Get all images Docker registry v2 adds a new The syntax is as follows:
By default, a maximum of 100 records are returned. If the number of records is greater than 100, you can specify the number of records to return by using the parameter Get the image tag To get the tag list of the docker image, you can use Operation Example A test docker registry is deployed locally for demonstration. I use httpie for testing. Get the mirror list: Call the
Get the tag list of the image Call
PowerShell script Any operation and maintenance that is not automated is a hooligan. It is very likely that there will be similar needs in the future. It is better to write a script to run it automatically. The following script is a bit simplified because there are not many images on our azure container registry, only about 50 or 60 images, and the image only has the latest tag, no other tags, so the above steps are simplified, and not all images are obtained by paging, nor all tags are obtained. If you actually use it, please modify it yourself before using it # variables $srcRegUser = "xxx" $srcRegPwd = "111111" $srcRegHost = "xxx.azurecr.cn" $destRegUser = "yyy" $destRegPwd = "222" $destRegHost = "registry.xxx.com" # get repositories from source registry # httpie $response = (http -b -a "${srcRegUser}:${srcRegPwd}" "https://${srcRegHost}/v2/_catalog") | ConvertFrom-Json # curl #$response = (curl -u "${srcRegUser}:${srcRegPwd}" "https://${srcRegHost}/v2/_catalog") | ConvertFrom-Json # repository $repositories = $response.repositories # Write-Host $repositories # login source registry docker login $srcRegHost -u $srcRegUser -p $srcRegPwd # login dest registry docker login $destRegHost -u $destRegUser -p $destRegPwd # sync foreach($repo in $repositories) { Write-Host "sync $repo begin" $srcTag = "${srcRegHost}/${repo}:latest" $destTag = "${destRegHost}/${repo}:latest" Write-Host "source image tag: $srcTag" Write-Host "dest image tag $destTag" Write-Host "docker pull $srcTag begin" docker pull $srcTag Write-Host "docker pull $srcTag completed" Write-Host "docker tag $srcTag $destTag ing" docker tag $srcTag $destTag Write-Host "docker push $destTag begin" docker push $destTag Write-Host "docker push $destTag completed" Write-Host "docker rmi $srcTag $destTag begin" docker rmi $srcTag $destTag Write-Host "docker rmi $srcTag $destTag end" Write-Host "sync $repo completed" } Write-Host "Completed..." More If you need to synchronize many images, consider using Alibaba Cloud's image synchronization tool to synchronize them. Reference https://stackoverflow.com/questions/31251356/how-to-get-a-list-of-images-on-docker-registry-v2 https://github.com/AliyunContainerService/image-syncer https://docs.docker.com/registry/spec/api/ Summarize This is the end of this article about docker registry image synchronization. For more related docker registry image content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Briefly understand the MYSQL database optimization stage
>>: A complete guide to CSS style attributes css() and width() in jQuery
Table of contents 1. Test experiment 2. Performan...
Async Hooks is a new feature of Node8. It provide...
Table of contents Example Method 1: delete Method...
Intro Introduces and collects some simple and pra...
Preface I believe that the syntax of MySQL is not...
In MySQL 8.0.18, a new Hash Join function was add...
Nginx logs can be used to analyze user address lo...
Preface: In the previous article, we mainly intro...
Effect The effect is as follows Implementation ...
Table of contents Create a global shared content ...
Often, after a web design is completed, the desig...
During normal project development, if the MySQL v...
The communication modes of vue3 components are as...
VMWare (Virtual Machine ware) is a "virtual ...
1. Edit the docker.service file vi /usr/lib/syste...