Last active
January 14, 2021 14:32
-
-
Save mremond/5e652dffa88ef0eef908048925ce568d to your computer and use it in GitHub Desktop.
Migrate from Docker Hub to Github Container Registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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