3 # Push all local repositories to a local registry
5 # Usage: ./push.sh docker-registry.example.com:5000
9 if [[ -z "${REGISTRY}" ]]
11 echo "usage: ${0} REGISTRY" >&2
15 DOCKER_IO=$(command -v docker.io)
16 DOCKER="${DOCKER:-${DOCKER_IO:-docker}}"
18 while read REPOSITORY TAG HASH OTHER
20 case "${REPOSITORY}" in
22 continue # not named or header line
25 continue # already registered
28 echo "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" &&
29 "${DOCKER}" tag -f "${HASH}" "${REGISTRY}/${REPOSITORY}:${TAG}" &&
30 echo "${DOCKER}" push "${REGISTRY}/${REPOSITORY}"
31 "${DOCKER}" push "${REGISTRY}/${REPOSITORY}"
32 done < <("${DOCKER}" images)