Last active
March 7, 2020 21:58
-
-
Save denniskupec/08c9ce15e8f8d8472adae69e95407e4e to your computer and use it in GitHub Desktop.
Tag and push all local Docker images to a private registry
This file contains hidden or 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 -e | |
# alias docker="docker.exe" | |
registry="registry.local:5000" | |
# list registry contents: | |
# curl -s "https://${registry}/v2/_catalog" | jq | |
for img in $(docker image ls | awk 'NR>1{ print $3; }') | |
do | |
[ "${img}" = "" ] || [ "${img}" = "<none>" ] && continue | |
fullname=$(docker image inspect --format='{{ index (.RepoTags) 0 | printf "%s" }}' ${img}) | |
if [ $(echo "${fullname}" | grep "${registry}") ]; then | |
echo "${img} already tagged" && continue | |
fi | |
docker image tag ${fullname} ${registry}/${fullname} | |
docker image push ${registry}/${fullname} | |
docker image rm ${fullname} | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment