Skip to content

Instantly share code, notes, and snippets.

@chinglinwen
Last active November 21, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chinglinwen/60f6650ed106a3e33f105438f75d191e to your computer and use it in GitHub Desktop.
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.
#!/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