From: W. Trevor King Date: Fri, 14 Feb 2014 20:35:32 +0000 (-0800) Subject: push.sh: Add a helper script to mass-push repositories to a registry X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=b12d60c3fc2bd843ca45ef9c00ba1d5ac15b259f;p=dockerfile.git push.sh: Add a helper script to mass-push repositories to a registry For example, after building, if you want to upload all of the new images. Any repositories that already exist on the registry will just be re-tagged. --- diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..447d50b --- /dev/null +++ b/push.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Push all local repositories to a local registry +# +# Usage: ./push.sh docker-registry.example.com:5000 + +REGISTRY="${1}" + +if [[ -z "${REGISTRY}" ]] +then + echo "usage: ${0} REGISTRY" >&2 + exit 1 +fi + +DOCKER_IO=$(command -v docker.io) +DOCKER="${DOCKER:-${DOCKER_IO:-docker}}" + +while read REPOSITORY TAG HASH OTHER +do + case "${REPOSITORY}" in + *none*|REPOSITORY) + continue # not named or header line + ;; + "${REGISTRY}"/*) + continue # already registered + ;; + esac + echo "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" && + "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" && + echo "${DOCKER}" push "${REGISTRY}/${REPOSITORY}" + "${DOCKER}" push "${REGISTRY}/${REPOSITORY}" +done < <("${DOCKER}" images)