Last active
October 19, 2017 10:52
-
-
Save dangtrinhnt/8afeb19cd26ceff3c35fa6475176102c to your computer and use it in GitHub Desktop.
Push all local registry's images to DockerHub
This file contains 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/bash | |
# | |
# This will push all the images from a local registry to DockerHub. For example: | |
# local_registry_domain/branch/image_name:my-tag -> docker_hub_username/image_name:my-tag | |
# | |
dh_username='' | |
dh_passwd='' | |
local_repo='' | |
local_branch='' | |
local_repo_path="$local_repo/$local_branch/" | |
local_tag='' | |
docker login -u $dh_username -p $dh_passwd | |
# list local images | |
local_images=$(docker images "$local_repo_path*" --format "{{.Repository}}") | |
for i in $local_images | |
do | |
img_name=${i//$local_repo_path/''} | |
old_tag="$i:$local_tag" | |
new_tag="$dh_username/$img_name:$local_tag" | |
# tag the image to match dockerhub repo | |
docker tag $old_tag $new_tag | |
# push the image to docker | |
docker push $new_tag | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment