treizeor

treizeor

V2EX member #152328, joined on 2015-12-21 15:55:11 +08:00
Per treizeor's settings, the topics list is hidden
Deals info, including closed deals, is not hidden
treizeor's recent replies
Dec 2, 2025
Replied to a topic by YDDDD 程序员 ssh 海外机器有延迟有啥好办法吗
tailscale 组网,很快
Sep 22, 2025
Replied to a topic by guiyun 程序员 有没有推荐的 FRP 服务提供商吗?
推荐用 tailscale 组网
一个 nas 一个硬盘柜
Jan 13, 2025
Replied to a topic by chevalier Android 2025 年 1 月帮推荐个安卓手机
华为 Pura70
Dec 31, 2024
Replied to a topic by sikuu2al 生活 一个词总结你的 2024!
操蛋
Dec 6, 2024
Replied to a topic by pauluswen Android P40 能刷机吗?
账号也是可以重置密码的,你不会连账号都忘了吧
Dec 5, 2024
Replied to a topic by molika 程序员 国内机器 docker 的镜像到底应该怎么拽?
#!/bin/bash -e

# 检查是否传递了目标参数
if [ $# -ne 1 ]; then
echo "Usage: $0 <docker image>"
exit
fi

IMG=$1

###############################################################################
# DockerHub 镜像源列表
DOCKERHUB_REGISTRY_MIRRORS=(
"docker.1panel.live"
"docker.unsee.tech"
"docker.m.daocloud.io"
"docker.kejilion.pro"
"registry.dockermirror.com"
"hub.rat.dev"
"dhub.kubesre.xyz"
"docker.nastool.de"
)

###############################################################################
# 检查本地是否已经存在 ${IMG}
if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^${IMG}$"; then
echo "镜像 ${IMG} 已经存在,跳过拉取步骤。"
exit 0
fi

# 遍历镜像源,拉取并打标签
for registry in "${DOCKERHUB_REGISTRY_MIRRORS[@]}"; do

registry_img=${registry}/${IMG}

# 检查本地是否已经存在 ${registry_img}
if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "^${registry_img}$"; then
echo "本地已经存在 ${registry_img},跳过拉取,进行打标签。"

# 为本地已有的镜像打标签为 ${IMG}
if docker tag ${registry_img} ${IMG}; then
echo "镜像 ${registry_img} 成功打标签为 ${IMG}。"
docker rmi ${registry_img} # 删除原镜像( registry 镜像源)
exit 0 # 成功后退出脚本
else
echo "为镜像 ${registry_img} 打标签失败!"
continue
fi
fi

echo "尝试从镜像源 ${registry} 拉取 ${IMG}..."

# 拉取镜像
if docker pull ${registry_img}; then
# 打标签为 ${IMG}
if docker tag ${registry_img} ${IMG}; then
echo "镜像 ${registry_img} 成功打标签为 ${IMG}。"
docker rmi ${registry_img} # 删除原镜像( registry 镜像源)
exit 0 # 成功后退出脚本
else
echo "为镜像 ${IMG} 打标签失败!"
docker rmi ${registry_img} # 删除失败的镜像
continue
fi
else
echo -e "从 ${registry} 拉取镜像失败,尝试下一个镜像源...\n"
continue
fi
done

echo "所有镜像源都尝试过,未能拉取并打标签 ${IMG}。"


# 保存为 docker-pull.shdocker-pull.sh 镜像
Nov 13, 2024
Replied to a topic by bigbugbag 程序员 macOS 中有 Oh My Zsh 的上位替代么?
折腾大半天就省这开启的一两秒,,,
Nov 12, 2024
Replied to a topic by igtheshyy NAS 家庭低配版 NAS 方案,大家看下是否可行?
我的 N1 插个 u 盘才是低配
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1034 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 70ms · UTC 19:01 · PVG 03:01 · LAX 12:01 · JFK 15:01
♥ Do have faith in what you're doing.