Last active
November 21, 2018 10:12
-
-
Save chinglinwen/60f6650ed106a3e33f105438f75d191e to your computer and use it in GitHub Desktop.
Convert all images to dockerhub, in case docker pull is blocked for the origin url.
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/sh | |
listfile="$1" | |
if [ "x$listfile" = "x" ]; then | |
echo "Usage: $0 example.list" | |
exit 1 | |
fi | |
basename="$( basename $listfile )" | |
base="$basename-$( date +%Y%m%d_%H%M%S )" | |
mkdir "$base" | |
sedfile="$base/$basename.sed" | |
# empyt it first for the repeatability | |
echo "file=$basename.yaml" >$sedfile | |
while read l; do | |
if [ "x$l" = "x" ]; then | |
continue | |
fi | |
img="$l" | |
newimg="$( echo $img | sed 's/\//-/g' )" | |
newtag="chinglinwen/$newimg" | |
echo "$img -> $newtag" | |
docker pull $img | |
docker tag $img $newtag | |
docker push $newtag | |
docker rmi $img | |
echo "$newtag done" | |
cat <<eof >> $sedfile | |
sed -i 's.${img},${newtag},' \$file | |
eof | |
done < $listfile | |
echo "try sed -i -f $sedfile some.yaml.file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment