Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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