Docker Community Forums

Share and learn in the Docker community.

Moving from DTR to a different Docker Registry

HI,

Our team has been asked to move all of the images from our docker trusted registry to a different (non dtr) registry.

As far as I’m aware there is no ‘easy’ way of doing this. Scripting is proving to be painful.

I had just wondered if anyone had approached this sort of thing before. Or if anyone has some suggestions.

Thanks

EDIT: Just thought I might add, the approach I had been taking so far is to:
Filter through all the needed images
Run ‘docker save’ on each one
‘docker load’ - retag if necessary
‘docker push’
Also - trying a simple ‘pull-retag-push’ isn’t proving as simple as it sounds

Why the docker save and docker load? Pull-retag-push works like a charm.

In case your image repos use a tls certifcate no trusted by your host, make sure to import its root ca certificate or the server certificate before (and restart the docker engine). Make sure to login on both image repos.

Things are not that hard if you use docker-compose.yml files
– filter all image lines
– iterate over the result
– process each line: split each line into old_server, repo and tag
– docker pul old_server/repo:tag
– docker tag old_server/repo:tag new_server/repo:tag
– docker push new_server/repo:tag

Here is a simplified snippet of what I used in my pre-kuberentes days. Though instead of spliting the line, in the image: value only the old server name is replaced with the new one.

file=$1
source_repo=dtr1.bla.com
target_repo=target.bla.com
if [ -n "$file" ] && [ -f $file ]; then
  images=$(grep 'image:' ${file} | awk -F" " '/image:/ {print $2}' | sort -u)
  for image in $images; do
    echo $image
    docker image pull $image
    target_image=${image/$source_repo/$target_repo}
    echo "tagging $image as $target_image"
    docker tag $image $target_image
    docker push $target_image
  done;
fi

Store it in a file and pass the path to your docker-compose.yml as parameter to the script.
Hint: instead of using a real docker-compose.yml, you could create a text file containing all the images as a simple list, just make sure each line start with any number of spaces and image:, like they would in docker-compose.yml

Though, If you want to move all images. You will need to use dtr’s rest api to query the catalog to get all existing image names and tags instead of parsing a docker-compose,yml.