常用镜像地址整理

作为程序猿,因为网络原因在天朝使用使用各种包管理器体验一般是不好的。本文整理了一些个人常用的镜像地址及其使用方式,包括Ubuntu的APT,PyPi,Conda,Docker的镜像以及GitHub的反向加速站点。

1. Ubuntu apt

2. PyPi

PyPi的镜像可就太多了,随便选一个都挺好用的.

  • BFSU
    1
    pip install -i https://mirrors.bfsu.edu.cn/pypi/web/simple <some-package>
  • OpenTUNA
    1
    pip install -i https://opentuna.cn/pypi/web/simple <some-package>
  • TencentCloud
    1
    pip install -i https://mirrors.cloud.tencent.com/pypi/simple <some-package>

使用以下命令将镜像设置为默认:

1
pip config set global.index-url https://mirrors.bfsu.edu.cn/pypi/web/simple

3. Conda

Conda因为版权原因,镜像站比较少,最近发现一个北京外国语大学的镜像站(目瞪口呆),速度挺快的,比清华镜像的速度和稳定性要好不少。

  • BFSU
    Anaconda 安装包可以到这里下载。Miniconda 安装包可以到这里下载。

使用BFSU镜像可以将~/.condarc修改为以下内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
- https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud

运行conda clean -i清除索引缓存,保证用的是镜像站提供的索引。

4. Docker

4.1 Docker CE

4.2 Docker Hub

对于使用 systemd 的系统(Ubuntu 16.04+、Debian 8+、CentOS 7), 在配置文件 /etc/docker/daemon.json 中加入:

1
2
3
4
5
6
{
"registry-mirrors": [
"https://mirror.baidubce.com",
"https://hub-mirror.c.163.com"
]
}

然后重新启动dockerd:sudo systemctl restart docker

5. Github && Github Release

对于GitHub来说,下面这些网络应该称为反向代理而不是镜像站。

5.1 HTTPS based Clone

  • CNPMJS

    1
    2
    git clone https://github.com/author/repo -> 
    git clone https://github.com.cnpmjs.org/author/repo
  • FastGit

    1
    2
    git clone https://github.com/author/repo -> 
    git clone https://hub.fastgit.org/author/repo

    为了方便起见,可以使用以下命令直接使用反向代理地址替代GitHub的地址:

    1
    git config --global url."https://github.com.cnpmjs.org/".insteadOf "https://github.com/"

5.2 SSH based Clone

  • github.zhlh6.cn
    1
    git@github.com:author/repo.git -> git@git.zhlh6.cn:author/repo.git
    原理:利用ucloud提供的GlobalSSH功能,对ssh协议数据进行加速。

5.3 Release Download

  • FastGit
    Release:
    1
    2
    https://github.com/author/repo/releases/download/1.0/1.0.tar.gz ->
    https://download.fastgit.org/author/repo/releases/download/1.0/1.0.tar.gz
    Codeload:
    1
    2
    https://github.com/author/repo/archive/master.zip ->
    https://download.fastgit.org/author/repo/archive/master.zip
  • CloudFlare (github.91chifun.workers.dev)
    Release:
    1
    2
    https://github.com/author/repo/releases/download/1.0/1.0.tar.gz ->
    https://github.91chifun.workers.dev/https://github.com/author/repo/releases/download/1.0/1.0.tar.gz
    Codeload:
    1
    2
    https://github.com/author/repo/archive/master.zip ->
    https://github.91chifun.workers.dev/https://github.com/author/repo/archive/master.zip