🦍 maniedzi's blog

Docker migration to another registry

A couple weeks ago, I got involved in another migration project. This one required the migration of Docker images and NuGet packages from ProGet (by Inedo) to Artifactory. 

I will put NuGet aside and focus on Docker migration first. 

Getting started

I spent some time searching for something already working. This took me to skopeo. With its copy subcommand, I was able to easily copy images from one registry to another:

$ skopeo copy docker://SOURCE_REGISTRY/IMAGE[:TAG] docker://TARGET_REGISTRY/IMAGE[:TAG]

I just needed to create a script that would generate the above command for every image and tag selected for migration.

While I didn't see any need for learning an API for ProGet, I have chosen the Docker Registry API to list all images and tags for migration.

I used the following endpoint to list all Docker images at the ProGet instance:

curl https://proget.local/v2/_catalog

And the one below to list all tags per image:

curl https://proget.local/v2/IMAGE/tags/list

I used Python with the requests module to create the migration script.

First, "requests" module is fetching a list of all available images in the feed selected for migration. For each image, "requests" module is fetching a list of all its tags. Next, based on the images and tags, it creates a string with the skopeo copy command and source and target registry. The output is saved to the migration.sh file. 

Migration

Having a script with a bunch of skopeo copy commands, I piped it to the tee program to have the logs of the process. 

sh migration.sh |  tee -a migration.log

scopeo handled it all very well, copying all images and tags without any issue.

Summary

I am glad I took the chance and searched for something already available instead of creating my own scripts. This way, I was able to finish the whole migration within two days.

#work