Created
January 3, 2023 08:51
-
-
Save MParvin/2b3ca37d784c4e0e27296b9579674e6d to your computer and use it in GitHub Desktop.
This script will pull an image from the public docker registry and push it to your 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/bash | |
private_registry="registry.example.com:5000" | |
if [ -z "$1" ]; then | |
echo "Usage: $0 <image_name>" | |
exit 1 | |
fi | |
image_name=$1 | |
docker pull $image_name || (echo "Failed to pull image $image_name" && exit 1) | |
docker tag $image_name $private_registry/$image_name || (echo "Failed to tag image $image_name" && exit 1) | |
echo "Pushing image $image_name to $private_registry" | |
docker push $private_registry/$image_name || (echo "Failed to push image $image_name" && exit 1) | |
echo -e "\n\nYour image is now available at $private_registry/$image_name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment