Skip to content

Instantly share code, notes, and snippets.

@ntheanh201
Created September 18, 2022 13:30
Show Gist options
  • Save ntheanh201/dae8a7b6456729d032da8f89c87c188b to your computer and use it in GitHub Desktop.
Save ntheanh201/dae8a7b6456729d032da8f89c87c188b to your computer and use it in GitHub Desktop.
Migrate docker image from Docker Hub to Github Container Registry
#! /bin/bash
read -p "Enter docker image: " image
read -p "Enter source docker image tag: " tag
read -p "Enter target docker image tag: " target_tag
github_user="ntheanh201"
docker_image="$github_user/$image:$tag"
new_image="ghcr.io/$github_user/$image:$target_tag"
echo "image: $docker_image"
echo "new image: $new_image"
docker pull $docker_image
docker tag $docker_image $new_image
docker push $new_image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment