Skip to content

Commit

Permalink
Update docker_retag_and_push.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
wuchangtai123 authored Jun 11, 2024
1 parent c99d2b9 commit 6f57a03
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions docker_retag_and_push.sh
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
#!/bin/bash

while read -r image; do
# 检查是否有 /
if [[ $image == *"/*"* ]]; then
# 截取 / 后的值
repository=$(basename "$image")
tag=$(echo "$image" | cut -d : -f 2)
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$repository:$tag"
else
# 如果没有 /,则直接使用原名称作为新的repository
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$image"
fi

# 拉取镜像,重新标记镜像,推送
docker pull --platform=linux/arm64 "$image"
docker tag "$image" "$new_image-arm64"
docker push "$new_image-arm64"

# 拉取镜像,重新标记镜像,推送
docker pull --platform=linux/amd64 "$image"
docker tag "$image" "$new_image-amd64"
docker push "$new_image-amd64"
function DockerImages() {
while read -r image; do
# 检查是否有 /
if [[ $image == *"/*"* ]]; then
# 截取 / 后的值
repository=$(basename "$image")
tag=$(echo "$image" | cut -d : -f 2)
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$repository:$tag"
else
# 如果没有 /,则直接使用原名称作为新的repository
new_image="registry.cn-hangzhou.aliyuncs.com/wct_registry/$image"
fi

# 拉取镜像,重新标记镜像,推送
docker pull --platform=linux/arm64 "$image"
docker tag "$image" "$new_image-arm64"
docker push "$new_image-arm64"

# 拉取镜像,重新标记镜像,推送
docker pull --platform=linux/amd64 "$image"
docker tag "$image" "$new_image-amd64"
docker push "$new_image-amd64"

#创建manifest
docker manifest create ${new_image} \
${new_image}-amd64 \
${new_image}-arm64 --amend

docker manifest push ${new_image}

done < images.txt
}

#创建manifest
docker manifest create ${new_image} \
${new_image}-amd64 \
${new_image}-arm64 --amend
DockerImages

docker manifest push ${new_image}

done < images.txt
exit 0

0 comments on commit 6f57a03

Please sign in to comment.