Skip to content

Instantly share code, notes, and snippets.

@MParvin
Created January 3, 2023 08:51
Show Gist options
  • Save MParvin/2b3ca37d784c4e0e27296b9579674e6d to your computer and use it in GitHub Desktop.
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
#!/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