Created
October 22, 2021 13:36
-
-
Save schwabix/58361d8f1068493021341e363048562f to your computer and use it in GitHub Desktop.
This file contains 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/env bash | |
while read image; do | |
original_image="old.repo.domain/${image}" | |
target_image="new.repo.domain/${image}" | |
# download all tags images | |
docker pull $original_image --all-tags | |
# get all images with format output to be: | |
# docker tag ORIGINAL_IMAGE_NAME:VERSION TARGET_IMAGE_NAME:VERSION | docker push TARGET_IMAGE_NAME:VERSION | |
# and execute those as commands | |
docker images $original_image \ | |
--format "docker tag {{.Repository}}:{{.Tag}} $target_image:{{.Tag}} | docker push $target_image:{{.Tag}}" | | |
bash | |
# remove local images | |
docker images | grep "${original_image}" | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi ${original_image}:{} | |
docker images | grep "${target_image}" | tr -s ' ' | cut -d ' ' -f 2 | xargs -I {} docker rmi ${target_image}:{} | |
done <docker-images.txt | |
# with docker-images.txt containing one image per lin |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment