Skip to content

Instantly share code, notes, and snippets.

@iwanbolzern
Created June 17, 2019 10:38
Show Gist options
  • Save iwanbolzern/7531413259db00da2b7f42fe6577e979 to your computer and use it in GitHub Desktop.
Save iwanbolzern/7531413259db00da2b7f42fe6577e979 to your computer and use it in GitHub Desktop.
Migrate one private docker registry into another
source_acr="my.private-registry.com:5000"
target_acr="my-other.private-registry.com:5001"
# read username password for source registry (needed to query api)
echo -n "Insert Username: "
read username
echo -n "Insert Password: "
read -s pw
echo
# get list with all repositories
url="https://${source_acr}/v2/_catalog"
echo "Downloading from: $url"
repos=$(curl -X GET \
-u $username:$pw \
$url | \
python -c "import sys, json; print(' '.join(json.load(sys.stdin)['repositories']))")
# migrate repositories
for repo in $repos; do
echo $repo
docker pull $source_acr/$repo --all-tags
docker image ls $source_acr/$repo \
--format "docker tag {{.Repository}}:{{.Tag}} $target_acr/$repo:{{.Tag}} | docker push $target_acr/$repo:{{.Tag}}" |
bash
docker image ls | grep $source_acr/$repo | awk '{print $3}' | xargs docker image rm -f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment