前言
因为一些不知名的原因,搞一些开发时如果从国外拉取包会特别慢,因此需要国内镜像的支持,例如清华镜像、阿里云镜像、中科大镜像等等,今天找一些开发过程中常用的镜像地址,汇总方便以后查阅。
Docker 镜像加速
Docker Hub 在国内访问极慢,以下是目前实测可用的加速源,配置后拉取速度可提升 5–10 倍。
| 镜像名称 | 地址 | 特点 |
|---|---|---|
| 毫秒镜像 | https://docker.ms | 稳定,公益服务 |
| 轩辕镜像 | https://docker.xuanyuan.me | 实测可用,速度快 |
| DaoCloud | https://docker.m.daocloud.io | 企业级,稳定性强 |
Linux 配置方式:
// /etc/docker/daemon.json
{
"registry-mirrors": [
"https://docker.ms",
"https://docker.m.daocloud.io"
]
}
配置后执行 sudo systemctl daemon-reload && sudo systemctl restart docker 生效。
Python / pip 镜像
PyPI 官方源在国内下载缓慢,推荐以下镜像源:
| 镜像名称 | 地址 | 特点 |
|---|---|---|
| 清华大学 TUNA | https://pypi.tuna.tsinghua.edu.cn/simple/ | 最广泛使用,更新及时 |
| 阿里云 | https://mirrors.aliyun.com/pypi/simple/ | 依托云资源,稳定性强 |
| 腾讯云 | https://mirrors.cloud.tencent.com/pypi/simple/ | 国内节点,速度快 |
永久配置方式(推荐):
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
临时使用:
pip install numpy -i https://pypi.tuna.tsinghua.edu.cn/simple/
Node.js / npm 镜像
npmmirror 是淘宝官方维护的 npm 镜像,每 10 分钟与官方同步一次,是目前最推荐的 npm 国内镜像。
- 镜像地址:
https://registry.npmmirror.com - 官网: npmmirror.com
配置方式:
# npm 全局设置
npm config set registry https://registry.npmmirror.com
# yarn
yarn config set registry https://registry.npmmirror.com
# pnpm
pnpm config set registry https://registry.npmmirror.com
项目级配置(在项目根目录创建 .npmrc):
registry=https://registry.npmmirror.com
旧地址
registry.npm.taobao.org已停用,请统一迁移至新地址。[6] [7]
Linux 系统包 / 综合软件镜像
清华大学 TUNA 镜像站是国内覆盖最全的综合镜像,涵盖 Ubuntu、Debian、CentOS、Homebrew、Conda 等几乎所有主流发行版和工具链。
| 用途 | 镜像地址 |
|---|---|
| 综合镜像站(清华) | https://mirrors.tuna.tsinghua.edu.cn |
| 综合镜像站(阿里云) | https://mirrors.aliyun.com |
| 综合镜像站(中科大) | https://mirrors.ustc.edu.cn |
Ubuntu apt 换源示例(清华):
# /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
Conda 换源(清华):
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
快速汇总
| 领域 | 推荐镜像 | 地址 |
|---|---|---|
| 🐳 Docker | 毫秒镜像 | https://docker.ms |
| 🐍 pip / Python | 清华 TUNA | https://pypi.tuna.tsinghua.edu.cn/simple/ |
| 📦 npm / Node.js | npmmirror | https://registry.npmmirror.com |
| 🐧 Linux apt/yum | 清华 TUNA | https://mirrors.tuna.tsinghua.edu.cn |
| 🐍 Conda | 清华 TUNA | https://mirrors.tuna.tsinghua.edu.cn/anaconda/ |
| ☕ Maven / Java | 阿里云 | https://maven.aliyun.com/repository/public |
| 🍺 Homebrew | 清华 TUNA | https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/ |
核心建议: 清华 TUNA 和阿里云镜像是"万能底座",几乎覆盖所有工具链;Docker 镜像因政策变动较频繁,建议收藏 github.com/dongyubin/D… 获取实时更新列表。