# 常用镜像地址整理

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

# 1. Ubuntu apt

# 2. PyPi

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

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

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

# 3. Conda

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

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

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
1
2
3
4
5
6
7
8
9
10
11
12
13

运行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 中加入:

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

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

# 5. Github && Github Release

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

# 5.1 HTTPS based Clone

  • CNPMJS (opens new window)

    git clone https://github.com/author/repo -> 
    git clone https://github.com.cnpmjs.org/author/repo
    
    1
    2
  • FastGit (opens new window)

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

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

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

# 5.2 SSH based Clone

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

# 5.3 Release Download

  • FastGit (opens new window) Release:
    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
    
    1
    2
    Codeload:
    https://github.com/author/repo/archive/master.zip ->
    https://download.fastgit.org/author/repo/archive/master.zip
    
    1
    2
  • CloudFlare (opens new window) (github.91chifun.workers.dev) Release:
    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
    
    1
    2
    Codeload:
    https://github.com/author/repo/archive/master.zip ->
    https://github.91chifun.workers.dev/https://github.com/author/repo/archive/master.zip
    
    1
    2