Aslinda yapmak istedigimiz iki docker registry arasinda veri kopyalamak, Bunun bir sebebi ilgili projede bir multiarch base image kullaniyor olmamiz ve bu nedenle multiarch base image i dockerhub dan cekip kendi repositorymize koyacagiz ki dockerhub limitleri ile ilgili problem yasamayalim.
Bunun icin gelistirilmis skopeo diye bir tool var.
Daha sonra bir registryden digerine kopyalama yapiyoruz.
skopeo copy --all \
--src-creds "$DOCKER_NEXUS_USER:$DOCKER_NEXUS_PASSWORD" \
--dest-creds "$DOCKER_NEXUS_USER:$DOCKER_NEXUS_PASSWORD" \
docker://$NEXUS_URL:9002/tomcat:10.1.44-jre21 \
docker://n$NEXUS_URL:9005/base-tomcat:10.1.44-jre21
burada –all tüm manifest leri ve ilk docker://…. source ikincisi destination.
Yani birinden alip birine push ediyoruz.
Daha sonra kontron etmek icin
docker buildx imagetools inspect $NEXUS_URL:9005/base-tomcat:10.1.44-jre21|grep arch
com.docker.official-images.bashbrew.arch: amd64
com.docker.official-images.bashbrew.arch: amd64
com.docker.official-images.bashbrew.arch: arm64v8
com.docker.official-images.bashbrew.arch: arm64v8
com.docker.official-images.bashbrew.arch: ppc64le
com.docker.official-images.bashbrew.arch: ppc64le
com.docker.official-images.bashbrew.arch: riscv64
com.docker.official-images.bashbrew.arch: riscv64
com.docker.official-images.bashbrew.arch: s390x
com.docker.official-images.bashbrew.arch: s390x
Birkac örnek.
echo "$NEXUS_REGISTRY_TOKEN" | skopeo login --username "$NEXUS_REGISTRY_USER" --password-stdin "$NEXUS_REGISTRY:$NEXUS_PULL_PORT"
echo "Copying image from dhi.io to nexus using skopeo..."
SOURCE_IMAGE="$DHI_REGISTRY/$TOMCAT_IMAGE_NAME:$TOMCAT_TAG"
TARGET_IMAGE="$NEXUS_REGISTRY:$NEXUS_PUSH_PORT/base-tomcat:$TOMCAT_TAG"
# Copy with latest tag using skopeo
echo "Copying to latest tag: $TARGET_IMAGE"
skopeo copy --all \
docker://$SOURCE_IMAGE \
docker://$TARGET_IMAGE
Skopeo ile image inspect yaparken gelen degerleri de jq ile karsilastirabiliriz.
NEXUS_REVISION=$(skopeo inspect docker://$NEXUS_REGISTRY:$NEXUS_PULL_PORT/base-tomcat:$TOMCAT_TAG –raw 2>/dev/null | jq -r ‘.annotations[“org.opencontainers.image.revision”]’ || echo “”)