cn-coding-mirrors 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ # Go(GOPROXY)
2
+
3
+ ```bash
4
+ # 写进 ~/.bashrc / ~/.zshrc(用户级,立即生效)
5
+ export GOPROXY="https://goproxy.cn,direct"
6
+ export GOSUMDB="sum.golang.org" # 或 off(不建议)
7
+ export GOPRIVATE="" # 私有仓库域名,逗号分隔,如 git.corp.com
8
+ ```
9
+
10
+ 备选(按顺位):
11
+
12
+ | 源 | URL |
13
+ |---|---|
14
+ | 七牛 | `https://goproxy.cn` |
15
+ | 阿里云 | `https://mirrors.aliyun.com/goproxy/` |
16
+ | 官方镜像 | `https://goproxy.io` |
17
+ | 腾讯云 | `https://mirrors.cloud.tencent.com/goproxy/` |
18
+
19
+ 持久化:`go env -w GOPROXY=https://goproxy.cn,direct`(写入 `$GOENV`,比 shell 变量更稳)。
20
+
21
+ ```bash
22
+ # 私有模块 + 公共代理共存
23
+ go env -w GOPROXY="https://goproxy.cn,direct"
24
+ go env -w GOPRIVATE="*.corp.example.com"
25
+ go env -w GONOSUMDB="*.corp.example.com"
26
+ ```
27
+
28
+ ## 验证
29
+
30
+ ```bash
31
+ go env GOPROXY
32
+ GOPROXY=https://goproxy.cn GONOSUMDB=* go install golang.org/x/tools/cmd/stringer@latest && echo go-ok
33
+ curl -sI -m 8 https://goproxy.cn/golang.org/x/text/@v/list | head -1
34
+ ```
@@ -0,0 +1,69 @@
1
+ # Java(maven、gradle、sbt)
2
+
3
+ ## maven
4
+
5
+ `~/.m2/settings.xml`(用户级,不需要 sudo):
6
+
7
+ ```xml
8
+ <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0">
9
+ <mirrors>
10
+ <mirror>
11
+ <id>aliyun-public</id>
12
+ <mirrorOf>central</mirrorOf>
13
+ <name>Aliyun Public</name>
14
+ <url>https://maven.aliyun.com/repository/public</url>
15
+ </mirror>
16
+ </mirrors>
17
+ </settings>
18
+ ```
19
+
20
+ 备选(按顺位):
21
+
22
+ | 源 | URL |
23
+ |---|---|
24
+ | 阿里云 | `https://maven.aliyun.com/repository/public` |
25
+ | 华为云 | `https://repo.huaweicloud.com/repository/maven/` |
26
+ | 腾讯云 | `https://mirrors.cloud.tencent.com/nexus/repository/maven-public/` |
27
+ | 中央仓库 | `https://repo1.maven.org/maven2` |
28
+
29
+ 需要 `plugin`/`google` 等仓库时,`<mirrorOf>*</mirrorOf>` 一把梭(会丢失细分仓库差异,可能引入解析差异,慎用)。
30
+
31
+ ## gradle
32
+
33
+ `~/.gradle/init.gradle`(全局生效,不污染项目):
34
+
35
+ ```groovy
36
+ allprojects {
37
+ repositories {
38
+ maven { url 'https://maven.aliyun.com/repository/public' }
39
+ maven { url 'https://maven.aliyun.com/repository/google' }
40
+ maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
41
+ mavenCentral()
42
+ }
43
+ }
44
+ ```
45
+
46
+ 或 `gradle.properties`:
47
+
48
+ ```properties
49
+ org.gradle.internal.repository.max.retries=5
50
+ systemProp.org.gradle.internal.http.connectionTimeout=60000
51
+ ```
52
+
53
+ ## sbt
54
+
55
+ `~/.sbt/repositories`:
56
+
57
+ ```properties
58
+ [repositories]
59
+ local
60
+ aliyun: https://maven.aliyun.com/repository/public
61
+ typesafe: https://repo.typesafe.com/typesafe/ivy-releases/,[organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]
62
+ ```
63
+
64
+ ## 验证
65
+
66
+ ```bash
67
+ mvn -q dependency:get -Dartifact=org.slf4j:slf4j-api:2.0.13 && echo maven-ok
68
+ curl -sI -m 8 https://maven.aliyun.com/repository/public/org/slf4j/slf4j-api/2.0.13/slf4j-api-2.0.13.pom | head -1
69
+ ```
@@ -0,0 +1,52 @@
1
+ # 其他生态(Flutter / PHP / .NET / R / Ruby / Helm)
2
+
3
+ ## Flutter / Dart
4
+
5
+ ```bash
6
+ export PUB_HOSTED_URL="https://pub.flutter-io.cn"
7
+ export FLUTTER_STORAGE_BASE_URL="https://storage.flutter-io.cn"
8
+ ```
9
+
10
+ ## PHP / Composer
11
+
12
+ ```bash
13
+ composer config -g repos.packagist composer https://mirrors.aliyun.com/composer/
14
+ # 或 ~/.composer/config.json 里 "packagist.org": {"type":"composer","url":"https://mirrors.aliyun.com/composer/"}
15
+ ```
16
+
17
+ ## .NET / NuGet
18
+
19
+ ```bash
20
+ dotnet nuget add source https://mirrors.huaweicloud.com/repository/nuget/v3/index.json -n huaweicloud
21
+ ```
22
+
23
+ ## R / CRAN
24
+
25
+ ```r
26
+ options(repos = c(CRAN = "https://mirrors.tuna.tsinghua.edu.cn/CRAN/"))
27
+ # 永久:写入 ~/.Rprofile
28
+ ```
29
+
30
+ ## Ruby / RubyGems
31
+
32
+ ```bash
33
+ gem sources --add https://mirrors.tuna.tsinghua.edu.cn/rubygems/ --remove https://rubygems.org/
34
+ bundle config mirror.https://rubygems.org https://mirrors.tuna.tsinghua.edu.cn/rubygems
35
+ ```
36
+
37
+ ## Helm
38
+
39
+ ```bash
40
+ # helm 二进制(华为云,实测 206 可下)
41
+ # https://mirrors.huaweicloud.com/helm/v3.16.2/helm-v3.16.2-linux-amd64.tar.gz
42
+ # 注意:https://mirrors.huaweicloud.com/helm/ 目录本身不可列,index.yaml 也 404,必须带具体版本路径
43
+ export HELM_MIRROR="https://mirrors.huaweicloud.com/helm"
44
+ ```
45
+
46
+ ## 验证
47
+
48
+ ```bash
49
+ flutter config --list 2>/dev/null | head -3
50
+ gem sources -l
51
+ Rscript -e 'getOption("repos")'
52
+ ```
@@ -0,0 +1,54 @@
1
+ # Node / JavaScript(npm、yarn、pnpm、二进制镜像)
2
+
3
+ ## registry
4
+
5
+ ```bash
6
+ # npm
7
+ npm config set registry https://registry.npmmirror.com
8
+ # 等价:~/.npmrc 里写 registry=https://registry.npmmirror.com
9
+
10
+ # yarn (v1)
11
+ yarn config set registry https://registry.npmmirror.com
12
+ # yarn berry: .yarnrc.yml -> npmRegistryServer: "https://registry.npmmirror.com"
13
+
14
+ # pnpm
15
+ pnpm config set registry https://registry.npmmirror.com
16
+ ```
17
+
18
+ 备选:`https://registry.npmmirror.com`(主)、`https://npm.mirrors.tuna.tsinghua.edu.cn`(tuna 已迁至 npmmirror,旧地址可能失效)、官方 `https://registry.npmjs.org`。
19
+
20
+ ## 二进制下载(安装卡 99% 的元凶)
21
+
22
+ ```bash
23
+ # 写进 ~/.bashrc,或项目 .npmrc
24
+ export NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node"
25
+ export NVM_NODEJS_ORG_MIRROR="https://npmmirror.com/mirrors/node"
26
+ export ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
27
+ export ELECTRON_BUILDER_BINARIES_MIRROR="https://npmmirror.com/mirrors/electron-builder-binaries/"
28
+ export SASS_BINARY_SITE="https://npmmirror.com/mirrors/node-sass"
29
+ export PUPPETEER_DOWNLOAD_HOST="https://cdn.npmmirror.com/binaries/chrome-for-testing"
30
+ export PUPPETEER_DOWNLOAD_BASE_URL="https://cdn.npmmirror.com/binaries/chrome-for-testing"
31
+ export PLAYWRIGHT_DOWNLOAD_HOST="https://npmmirror.com/mirrors/playwright"
32
+ export CYPRESS_DOWNLOAD_MIRROR="https://npmmirror.com/mirrors/cypress"
33
+ export PHANTOMJS_CDNURL="https://npmmirror.com/mirrors/phantomjs"
34
+ export SHARP_DIST_BASE_URL="https://npmmirror.com/mirrors/sharp"
35
+ export SENTRYCLI_CDNURL="https://npmmirror.com/mirrors/sentry-cli"
36
+ export npm_config_registry="https://registry.npmmirror.com"
37
+ ```
38
+
39
+ `.npmrc` 项目级等价(可提交到仓库):
40
+
41
+ ```ini
42
+ registry=https://registry.npmmirror.com
43
+ electron_mirror=https://npmmirror.com/mirrors/electron/
44
+ sass_binary_site=https://npmmirror.com/mirrors/node-sass
45
+ puppeteer_download_base_url=https://cdn.npmmirror.com/binaries/chrome-for-testing
46
+ ```
47
+
48
+ ## 验证
49
+
50
+ ```bash
51
+ npm config get registry
52
+ npm view react version --registry=https://registry.npmmirror.com
53
+ curl -sI -m 8 https://registry.npmmirror.com/react | head -1
54
+ ```
@@ -0,0 +1,87 @@
1
+ # Python(pip / uv / poetry / pdm / conda)
2
+
3
+ ## 源优先级
4
+
5
+ | 顺位 | 源 | 备注 |
6
+ |---|---|---|
7
+ | 1 | `https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple` | 最稳,全量同步 |
8
+ | 2 | `https://mirrors.aliyun.com/pypi/simple` | 快,偶有同步延迟 |
9
+ | 3 | `https://mirrors.cloud.tencent.com/pypi/simple` | 备用 |
10
+ | 4 | `https://mirrors.ustc.edu.cn/pypi/simple` | 常返回 403,最后考虑 |
11
+ | 5 | `https://pypi.org/simple` | 官方(可用但慢) |
12
+
13
+ > 实测(2025):tuna / aliyun / tencent 均 200;ustc 403;华为云 `mirrors.huaweicloud.com/repository/pypi/simple` 会 429 限流。
14
+
15
+ ## pip
16
+
17
+ ```bash
18
+ # 全局(推荐,用户级)
19
+ mkdir -p ~/.pip && cat > ~/.pip/pip.conf <<'EOF'
20
+ [global]
21
+ index-url = https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
22
+ extra-index-url = https://mirrors.aliyun.com/pypi/simple
23
+ trusted-host = mirrors.tuna.tsinghua.edu.cn
24
+ mirrors.aliyun.com
25
+ timeout = 60
26
+ EOF
27
+
28
+ # 单次
29
+ pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple <pkg>
30
+ ```
31
+
32
+ ## uv
33
+
34
+ ```bash
35
+ # 环境变量(~/.bashrc 或 ~/.config/uv/uv.toml)
36
+ export UV_DEFAULT_INDEX="https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
37
+ # uv.toml 等价写法
38
+ # [[index]]
39
+ # url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
40
+ # default = true
41
+
42
+ # 单次
43
+ uv pip install --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple <pkg>
44
+ uv tool install <pkg> --index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
45
+ ```
46
+
47
+ > uv 下载 Python 解释器走 `github.com/astral-sh/python-build-standalone`,国内可能卡住:
48
+ > `export UV_PYTHON_INSTALL_MIRROR="https://ghproxy.net/https://github.com/astral-sh/python-build-standalone/releases/download"`
49
+ > 拉取 GitHub release 资产统一用技能 `gh-download`。
50
+
51
+ ## poetry / pdm
52
+
53
+ ```toml
54
+ # pyproject.toml
55
+ [[tool.poetry.source]]
56
+ name = "tuna"
57
+ url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
58
+ priority = "primary"
59
+
60
+ # pdm: ~/.config/pdm/config.toml
61
+ # [pypi]
62
+ # url = "https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple"
63
+ ```
64
+
65
+ ## conda / mamba
66
+
67
+ ```bash
68
+ cat > ~/.condarc <<'EOF'
69
+ channels:
70
+ - defaults
71
+ default_channels:
72
+ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
73
+ - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
74
+ custom_channels:
75
+ conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
76
+ pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
77
+ show_channel_urls: true
78
+ EOF
79
+ ```
80
+
81
+ ## 验证
82
+
83
+ ```bash
84
+ pip config list | grep index-url
85
+ uv pip install --dry-run requests 2>&1 | head -3
86
+ python -c "import urllib.request as u;print(u.urlopen('https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple/',timeout=8).status)"
87
+ ```
@@ -0,0 +1,38 @@
1
+ # Rust(cargo / rustup)
2
+
3
+ ## cargo 稀疏索引(推荐,无需 git clone 索引)
4
+
5
+ `~/.cargo/config.toml`:
6
+
7
+ ```toml
8
+ [source.crates-io]
9
+ replace-with = "rsproxy-sparse"
10
+
11
+ [source.rsproxy-sparse]
12
+ registry = "sparse+https://rsproxy.cn/index/"
13
+
14
+ [registries.rsproxy]
15
+ index = "https://rsproxy.cn/crates.io-index"
16
+
17
+ [net]
18
+ git-fetch-with-cli = true
19
+ retry = 5
20
+ ```
21
+
22
+ 备选:字节 `https://rsproxy.cn`、中科大 `https://mirrors.ustc.edu.cn/crates.io-index`(git 索引)、
23
+ 清华 `sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/`。
24
+
25
+ ## rustup / 工具链
26
+
27
+ ```bash
28
+ export RUSTUP_DIST_SERVER="https://rsproxy.cn"
29
+ export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"
30
+ ```
31
+
32
+ ## 验证
33
+
34
+ ```bash
35
+ cargo search serde --limit 1 # 能返回结果说明索引通
36
+ cargo add anyhow --dry-run 2>&1 | head -3
37
+ curl -sI -m 8 https://rsproxy.cn/index/se/rd/serde | head -1
38
+ ```
@@ -0,0 +1,51 @@
1
+ # 系统包(apt / apk / dnf / brew)
2
+
3
+ ## Ubuntu / Debian(apt)
4
+
5
+ ```bash
6
+ # 备份再改,永远先备份
7
+ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F)
8
+ sudo sed -i 's|http://archive.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g;
9
+ s|http://security.ubuntu.com|https://mirrors.tuna.tsinghua.edu.cn|g' /etc/apt/sources.list
10
+ sudo apt update
11
+ ```
12
+
13
+ Ubuntu 22.04+ 若使用 `/etc/apt/sources.list.d/ubuntu.sources`(deb822 格式),改 `URIs:` 字段。
14
+ 24.04 起还可能存在 `ubuntu.sources` + `debian.sources`,注意一并处理。
15
+
16
+ | 源 | URL |
17
+ |---|---|
18
+ | 清华 | `https://mirrors.tuna.tsinghua.edu.cn/ubuntu/` |
19
+ | 阿里云 | `https://mirrors.aliyun.com/ubuntu/` |
20
+ | 中科大 | `https://mirrors.ustc.edu.cn/ubuntu/` |
21
+ | 华为云 | `https://repo.huaweicloud.com/ubuntu/` |
22
+
23
+ ## Alpine(apk)
24
+
25
+ ```sh
26
+ sed -i 's|dl-cdn.alpinelinux.org|mirrors.tuna.tsinghua.edu.cn|g' /etc/apk/repositories
27
+ apk update
28
+ ```
29
+
30
+ ## CentOS / Rocky / Fedora(dnf/yum)
31
+
32
+ ```bash
33
+ sudo sed -i 's|^mirrorlist=|#mirrorlist=|; s|^#baseurl=http://mirror.centos.org|baseurl=https://mirrors.tuna.tsinghua.edu.cn|' /etc/yum.repos.d/*.repo
34
+ sudo dnf makecache
35
+ ```
36
+
37
+ ## Homebrew
38
+
39
+ ```bash
40
+ export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
41
+ export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
42
+ export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
43
+ export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
44
+ ```
45
+
46
+ ## 验证
47
+
48
+ ```bash
49
+ grep -h '^deb\|^URIs' /etc/apt/sources.list /etc/apt/sources.list.d/*.sources 2>/dev/null | head -3
50
+ sudo apt -o Acquire::http::Timeout=10 update -qq && echo apt-ok
51
+ ```
@@ -0,0 +1,58 @@
1
+ # 版本控制与代码托管(GitHub 加速、hg、svn)
2
+
3
+ ## GitHub 文件下载
4
+
5
+ **不要裸 curl**。用 `ghproxy` 前缀或直接上技能 `gh-download`(分片 + 校验 + 镜像轮转):
6
+
7
+ ```bash
8
+ # 单文件
9
+ curl -fL -o out.tgz "https://ghproxy.net/https://github.com/owner/repo/releases/download/v1.0.0/asset.tar.gz"
10
+ # 推荐:分片 + sha256 校验 + 自动挑资产
11
+ bash <this-skill-dir>/../gh-download/scripts/ghdl owner/repo@v1.0.0 -a linux-amd64 -o out.tgz -n 8
12
+ ```
13
+
14
+ 可用代理前缀(实测):`https://ghproxy.net/`、`https://ghfast.top/`、`https://gh-proxy.com/`。
15
+ 不可用:`https://ghproxy.cc/`(证书不匹配)、直连 `github.com` release 资产。
16
+ `api.github.com` 可直连(查版本、列资产),只有下载/克隆需要代理。
17
+
18
+ ## git clone 加速
19
+
20
+ ```bash
21
+ git clone https://ghproxy.net/https://github.com/owner/repo.git
22
+ # 或全局改写(谨慎,会影响所有 https github 地址)
23
+ git config --global url."https://ghproxy.net/https://github.com/".insteadOf "https://github.com/"
24
+ ```
25
+
26
+ 只对特定仓库生效更安全:
27
+
28
+ ```bash
29
+ git config --global url."https://ghproxy.net/https://github.com/big-org/".insteadOf "https://github.com/big-org/"
30
+ ```
31
+
32
+ ## Mercurial(hg)
33
+
34
+ hg 没有成熟的国内公共镜像;常见做法是**只镜像单个仓库**或用代理:
35
+
36
+ ```bash
37
+ # 用 ghproxy 风格企业代理包装任意 https 源
38
+ hg clone https://ghproxy.net/https://hg.example.com/repo
39
+ # 或配置 http_proxy 走本地/公司代理
40
+ hg --config http_proxy.host=127.0.0.1:7890 clone https://hg.mozilla.org/mozilla-central
41
+ ```
42
+
43
+ 大仓库建议 `--config format.usefncache=0 --config format.usestore=1 --config format.use-share-extension=1` 之外,
44
+ 优先考虑官方 `hg.mozilla.org` 的 bundle 发行包(`*.hg` 打包文件),比逐 changeset 拉取快一个数量级。
45
+
46
+ ## Subversion(svn)
47
+
48
+ ```bash
49
+ svn checkout https://ghproxy.net/https://github.com/owner/repo/trunk # 仅当仓库暴露 trunk
50
+ # 常用:svn 走公司镜像或 http_proxy
51
+ ```
52
+
53
+ ## 验证
54
+
55
+ ```bash
56
+ git ls-remote https://ghproxy.net/https://github.com/sharkdp/fd.git HEAD # 应返回 HEAD sha
57
+ curl -sI -m 8 https://ghfast.top/https://github.com/sharkdp/fd/releases/latest | head -1
58
+ ```
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: docker-pull
3
+ description: 用国内镜像源按 registry v2 协议分片拉取 Docker/OCI 镜像(ghcr.io、docker.io、gcr.io、quay.io、registry.k8s.io),逐层 sha256 校验后合成镜像并 docker load,绕开直连限速。当 docker pull 卡住/超时、拉 ghcr.io 镜像极慢、或需要离线导出镜像 tar 时使用。Use when `docker pull` stalls or is throttled in mainland China and you need chunked parallel image download through domestic registry mirrors.
4
+ license: MIT
5
+ compatibility: 需要 python3.8+(仅标准库)与 docker CLI(`--no-load` 时不需要 docker)。目标镜像需可匿名拉取。
6
+ metadata:
7
+ author: cn-coding-mirrors
8
+ scope: china-network
9
+ ---
10
+
11
+ # docker-pull:国内镜像源分片拉取容器镜像
12
+
13
+ `docker pull ghcr.io/...` 在国内常被限速到几十 KB/s(实测 0.07 MB/s)。本技能直接按 registry v2 API
14
+ 拉 manifest 与各 layer,走国内镜像源并发分片,最后按 `docker save` 格式合成并 `docker load`。
15
+
16
+ 实测:`ghcr.io/usestrix/strix-sandbox:1.3.0`(1.38 GB / 35 层)**155 秒**完成加载。
17
+
18
+ ## 用法
19
+
20
+ ```bash
21
+ python3 scripts/dpull ghcr.io/owner/app:1.2.3 # 下载 + 自动 docker load
22
+ python3 scripts/dpull alpine:3.20 -j 16 -c 8 # 每层 16 分片,每片 8 MiB
23
+ python3 scripts/dpull ghcr.io/o/a:tag --no-load -o /tmp/a.tar # 只产 tar(离线分发/导入他机)
24
+ python3 scripts/dpull nvcr.io/o/a:1 --mirror ghcr.nju.edu.cn --mirror-only
25
+ ```
26
+
27
+ | 选项 | 说明 |
28
+ |---|---|
29
+ | `-j N` | 每层并发分片数(默认 8) |
30
+ | `-c MB` | 分片大小(默认 16 MiB) |
31
+ | `--platform` | 目标平台,默认 `linux/amd64`(manifest list 里自动挑) |
32
+ | `--mirror HOST` | 追加镜像源;环境变量 `DPULL_MIRRORS` 亦可 |
33
+ | `--mirror-only` | 只用显式指定的镜像源 |
34
+ | `--no-mirror` | 直连官方 registry(境外网络) |
35
+ | `--no-load` | 只生成 tar,不 `docker load` |
36
+ | `-o FILE` / `--keep-tar` | 指定 tar 路径 / 保留 tar |
37
+ | `--cache DIR` | 内容寻址缓存(默认 `~/.cache/dpull`),重复层直接命中 |
38
+ | `-q` | 静默,stdout 只打印镜像引用 |
39
+
40
+ ## 内置镜像源链
41
+
42
+ | 官方 registry | 国内镜像(按顺位,失败自动轮转) |
43
+ |---|---|
44
+ | `ghcr.io` | `ghcr.nju.edu.cn`、`ghcr.m.daocloud.io` |
45
+ | `docker.io` | `docker.m.daocloud.io`、`docker.1panel.live`、`hub.rat.dev` |
46
+ | `gcr.io` | `gcr.m.daocloud.io` |
47
+ | `quay.io` | `quay.m.daocloud.io` |
48
+ | `registry.k8s.io` / `k8s.gcr.io` | `k8s.m.daocloud.io` |
49
+
50
+ 启动时并发预探测各源,403/连不通的会被剔除并提示;分片失败会轮转到下一个源。
51
+
52
+ ## 原理与边界
53
+
54
+ 1. `GET /v2/<repo>/manifests/<ref>`(带 `Accept` 协商 OCI index / docker manifest list),按平台选 digest。
55
+ 2. 每个 blob(config + 各 layer)先探测大小,再按 Range 分片并发下载,**逐 blob 校验 sha256**。
56
+ 3. 组装成 `docker save` 兼容 tar:`blobs/sha256/*` + `manifest.json`(带 RepoTags) + OCI `index.json` + `oci-layout`。
57
+ 4. `docker load -i` 导入,标签保持原引用。
58
+
59
+ 限制:
60
+ - **仅匿名拉取**(公开镜像)。私有镜像需要 registry token/登录,本脚本不处理。
61
+ - 单 registry 若无任何可用国内镜像,会退回官方直连(可能很慢)。
62
+ - 缓存占磁盘,镜像调完可删 `~/.cache/dpull`。
63
+
64
+ ## 何时不要用
65
+
66
+ - 只想配 daemon 级加速且加速器可用:直接改 `/etc/docker/daemon.json` 的 `registry-mirrors`(见技能 `cn-coding-mirrors` 的 `references/docker.md`)。
67
+ - 下载 GitHub release 文件:用技能 `gh-download`。
68
+
69
+ ## 验证
70
+
71
+ ```bash
72
+ python3 scripts/dpull alpine:3.20 -q # 应输出 alpine:3.20
73
+ docker images alpine --format '{{.Repository}}:{{.Tag}} {{.Size}}'
74
+ ```