Created
December 3, 2020 03:42
-
-
Save kwonghung-YIP/0cfa8a37cb6394116275cd3e278a058c to your computer and use it in GitHub Desktop.
[docker-CLI] Re-tag and Re-push the images that used by running containers to your private image registry
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/bash | |
docker login -u <<registry login>> -p <<password>> <<user registry host>> | |
docker ps -a --format "{{.ID}} {{.Image}}" | grep <<your registry prefix>> | \ | |
while read line | |
do | |
ctrid=`echo $line | awk '{print $1}'` | |
imgtag=`echo $line | awk '{print $2}'` | |
imgdigest=`docker container inspect --format "{{.Config.Image}}" $ctrid` | |
#echo "container id : $ctrid" | |
#echo "image tag : $imgtag" | |
#echo "image digest : $imgdigest" | |
docker image tag $imgdigest $imgtag | |
docker image push $imgtag | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment