From b12d60c3fc2bd843ca45ef9c00ba1d5ac15b259f Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Fri, 14 Feb 2014 12:35:32 -0800 Subject: [PATCH] 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. --- push.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 push.sh 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) -- 2.26.2