Skip to content

Instantly share code, notes, and snippets.

@mremond
Last active January 14, 2021 14:32
Show Gist options
  • Save mremond/5e652dffa88ef0eef908048925ce568d to your computer and use it in GitHub Desktop.
Save mremond/5e652dffa88ef0eef908048925ce568d to your computer and use it in GitHub Desktop.
Migrate from Docker Hub to Github Container Registry
#!/bin/bash
# Script to move an image from Docker Hub to Github container registry
original_image="ejabberd/ecs"
target_image="processone/ejabberd"
target_acr="ghcr.io"
# list of tag matches to ignore (i.e. "beta|rc")
grep_filter="<none>"
# Download all image tags
docker pull $original_image --all-tags
# For all tags for that image, tag them and push them to new registry
# (using tac to create the tags in chronological order)
docker images $original_image \
--format "docker tag {{.Repository}}:{{.Tag}} $target_acr/$target_image:{{.Tag}} | docker push $target_acr/$target_image:{{.Tag}}" |
grep -vE $grep_filter |
tac |
bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment