Skip to main content

Moving containers from to

Learn more with this short example on how to move container images from the registry to
snail moving a shipping container on its back.

Image by Fırat Eskici @

Thanks to Skopeo, we can easily copy container images from one registry to another. In this article, we’ll copy images from to, a container registry that has a lot of features that doesn’t provide. The first feature that I really like is the ability to list and manage image vulnerabilities and other security information. The second is the ability to manage image manifests.

I wrote a small script that one can use to automate image copying. Before running the script, do the following:

  1. Get an OAuth token from[your-org]?tab=applications.
  2. Change the token, namespace, containers, and tag (if needed).
  3. If your registry requires authentication, run podman login ( the –src-creds option can also be used with Skopeo).
  4. Authenticate against your registry with podman login (the –dest-creds option can also be used with Skopeo).

Here is the script:

set -ex

# get OAuth token from[your-org]?tab=applications
containers='app1 app2'

retry() {
    local -r -i max_attempts="$1"; shift
    local -r cmd="$@"
    local -i attempt_num=1
    until $cmd
        if ((attempt_num==max_attempts))
            echo "Attempt $attempt_num failed and there are no more attempts left!"
            return 1
            echo "Attempt $attempt_num failed! Trying again in $attempt_num seconds..."
            sleep $((attempt_num++))

for container in $containers; do
    # create empty public repo first otherwise skopeo will create the image as private
    curl -X POST \
        -d '{"namespace":"'$namespace'","repository":"'$container'","description":"Container image '$container'","visibility":"public"}' \
        -H 'Authorization: Bearer '$token'' -H "Content-Type: application/json"
    # workaround if returns 500 error, likely due to an internal bug when using skopeo against
    copy="skopeo copy docker://$namespace/$container:$tag docker://$namespace/$container:$tag"
    retry 5 $copy

As you can see, there are two unusual things in this script. First, the curl command creates an empty public image; otherwise, would create a private image by default when copying the image with Skopeo. As far as I know, there is no option in to change the default policy. Of course, you can remove it if you don’t want your image to be public by default.

Second, the retry mechanism works around the 500 error that tells you that the repository already exists when Skopeo provisions a new repository (which sounds specific to how the registry receives authentication from Skopeo vs. Docker CLI).

For more information, check out the documentation.

Enjoy Skopeo and!

This article was originally posted on /home/emilien.

Topics:   Containers  
Author’s photo

Emilien Macchi

Software Engineer at Red Hat, Private Pilot, French guy hiding somewhere in Canada. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.