镜像源加速下载

对于一些服务,国内的服务器下载的速度很慢,这时我们可以使用一些镜像源来加速下载。

Docker

0. docker install

  • docker.io
    sudo apt install docker.io

1. 使用cf Workers自建

https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6

cf自建1: https://github.com/yaming116/docker-pull-proxy/blob/main/worker.js

cf自建2: https://github.com/mzzsfy/Dockerfile/blob/main/cf-worker/docker-image.js

cf自建3: https://github.com/ciiiii/cloudflare-docker-proxy/blob/master/src/index.js

cf自建4: https://github.com/lework/cloudflare-workers/blob/master/docker_proxy.js

在Works和Pages填入下面的代码后,需要添加对应的DNS记录(随便填,可以填8.8.8.8)和绑定Works路由(“docker.xxx.xyz/*”与对应Works绑定)。

2. 一些docker镜像源

(不稳定,强烈建议使用cf自建)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
https://docker.m.daocloud.io  # 慢
https://docker.chenby.cn
https://docker.1panel.live
https://hub.rat.dev
https://hub.uuuadc.top
https://docker.anyhub.us.kg
https://dockerhub.jobcher.com
https://dockerhub.icu
https://docker.ckyl.me
https://docker.awsl9527.cn
https://docker.hpcloud.cloud
https://ustc-edu-cn.mirror.aliyuncs.com # 版本非常旧
https://ccr.ccs.tencentyun.com #旧
https://atomhub.openatom.cn # 部分镜像可用,300多,旧

3. Linux修改

修改/etc/docker/daemon.json配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
sudo mkdir -p /etc/docker
sudo vim /etc/docker/daemon.json
# 配置单个mirror
{
"registry-mirrors": ["https://docker.chenby.cn"]
}
# 配置多个mirror
{
"registry-mirrors": [
"https://docker.chenby.cn",
"https://docker.m.daocloud.io",
"https://docker.1panel.live",
"https://hub.rat.dev",
"https://hub.uuuadc.top"
]
}
# 或者
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.chenby.cn",
"https://docker.m.daocloud.io",
"https://docker.1panel.live",
"https://hub.rat.dev",
"https://hub.uuuadc.top"
]
}
EOF
# 重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker

# 使用一下命令查看是否配置成功
docker info
# Registry Mirrors:
# [...]
# https://docker.m.daocloud.io

4. 群晖修改

4.1 修改注册表方式

对于群晖来说需要依次点击docker->注册表->设置->编辑Docker Hub->勾选启动注册表镜像和信任SSL自我签署证书,在注册表镜像URL里填写更换镜像源的链接。最后重启Docker和DSM(不一定需要),如下图方式。

4.2 命令行或docker-compose附加

也可以使用命令行docker pull,或者使用docker-compose,只需要在image的前面加上镜像前缀即可。

1
2
docker pull docker.m.daocloud.io/linuxserver/emby:latest
image: "docker.m.daocloud.io/linuxserver/emby:latest"
4.3 修改环境变量(不建议)

群晖可以参考以下链接进行尝试修改,修改前请备份对应文件!

https://www.v2ex.com/t/981481#r_14833577
https://post.m.smzdm.com/p/ag82opxd/

其他的地址

gcr.io >>>>> gcr.chenby.cn
quay.io >>>>> quay.chenby.cn
ghcr.io >>>>> ghcr.chenby.cn
docker.io >>>>> docker.chenby.cn
k8s.gcr.io >>>>> k8s.chenby.cn
registry.k8s.io >>>>> k8s.chenby.cn
docker.elastic.co >>>>> elastic.chenby.cn
docker.cloudsmith.io >>>>> cloudsmith.chenby.cn

cr.l5d.io >>>>> l5d.m.daocloud.io
docker.elastic.co >>>>> elastic.m.daocloud.io
docker.io >>>>> docker.m.daocloud.io
gcr.io >>>>> gcr.m.daocloud.io
ghcr.io >>>>> ghcr.m.daocloud.io
k8s.gcr.io >>>>> k8s-gcr.m.daocloud.io
registry.k8s.io >>>>> k8s.m.daocloud.io
mcr.microsoft.com >>>>> mcr.m.daocloud.io
nvcr.io >>>>> nvcr.m.daocloud.io
quay.io >>>>> quay.m.daocloud.io
registry.jujucharms.com >>>>> jujucharms.m.daocloud.io
rocks.canonical.com >>>>> rocks-canonical.m.daocloud.io

Ubuntu/Debian/Centos加速下载

1
2
3
4
5
6
7
https://mirrors.tuna.tsinghua.edu.cn # 清华大学
http://mirrors.ustc.edu.cn # 中国科学技术大学
https://developer.aliyun.com/mirror # 阿里云
http://mirrors.163.com # 网易
https://debian.bjtu.edu.cn # 北京交通大学
http://mirrors.sohu.com #搜狐
# 越往下越慢

1.Ubuntu

1
2
3
4
5
6
7
lsb_release -a # 查看版本
sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup #存个备份
vim /etc/apt/sources.list
# 或者
sudo tee > /etc/apt/sources.list <<EOF
# 源
EOF

清华源

Ubuntu12

1
2
3
4
5
6
sudo tee > /etc/apt/sources.list <<EOF
deb http://mirrors.aliyun.com/oldubuntu-releases/ubuntu precise main universe restricted multiverse
deb http://mirrors.aliyun.com/oldubuntu-releases/ubuntu precise-security universe main multiverse restricted
deb http://mirrors.aliyun.com/oldubuntu-releases/ubuntu precise-updates universe main multiverse restricted
deb http://mirrors.aliyun.com/oldubuntu-releases/ubuntu precise-proposed universe main multiverse restricted
EOF
14.04 LTS

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ trusty-proposed main restricted universe multiverse
16.04 LTS

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-proposed main restricted universe multiverse
18.04 LTS

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
20.04 LTS

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-proposed main restricted universe multiverse
21.04

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ hirsute-proposed main restricted universe multiverse
21.10

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ impish-proposed main restricted universe multiverse
22.04 LTS

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# 预发布软件源,不建议启用
# deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse
1
2
3
sudo apt-get update
sudo apt-get upgrade
# 出现tsinghua证明成功

2.Debian

清华源

3.Centos

清华源

cmd

临时生效

1
2
3
4
5
6
7
8
9
10
11
# 使用sock5代理
set http_proxy=socks5://127.0.0.1:7890
set https_proxy=socks5://127.0.0.1:7890

# 使用http代理
set http_proxy=http://127.0.0.1:7890
set https_proxy=http://127.0.0.1:7890

# 如果代理服务器要账户和密码
set http_proxy_user=username
set http_proxy_pass=password

取消

1
2
3
# 留空即可
set http_proxy=
set https_proxy=

永久生效

右键【我的电脑 】-> 属性 -> 高级系统设置 -> 高级 -> 环境变量 -> 系统环境变量

变量
http_proxy http://127.0.0.1:7890
https_proxy http://127.0.0.1:7890
# 账户和密码(如果有的话)
http_proxy_user username
http_proxy_pass password

git

参考之前写的

点击跳转

pip

1
2
3
4
5
http://mirrors.aliyun.com/pypi/simple/ # 阿里云 
http://pypi.douban.com/simple/ # 豆瓣
https://pypi.tuna.tsinghua.edu.cn/simple/ # 清华大学
http://pypi.mirrors.ustc.edu.cn/simple/ # 中国科学技术大学
http://pypi.hustunique.com/ # 华中科技大学

1.临时使用:

可以在使用pip的时候,加上参数-i和镜像地址

1
2
3
4
# 从清华镜像安装pandas库,或者为pip3
[/usr/bin/]python3 -m pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
# 安装到对应python上
[/usr/bin/]python3 -m pip install pandas -i https://pypi.tuna.tsinghua.edu.cn/simple

2.永久修改

推荐使用
1
2
3
4
# 安装到对应python上,或者为pip3
[/usr/bin/]python3 -m pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
[/usr/bin/]python3 -m pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn
[/usr/bin/]python3 -m pip config list
1
2
# 配置多个镜像源
[/usr/bin/]python3 pip config set global.extra-index-url "<url1> <url2>..."
a. Linux
1
2
3
4
5
6
7
8
9
10
vim ~/.pip/pip.conf # 在用户根目录下 ~ 下创建 .pip 隐藏文件夹
# 没有就创建一个文件夹及文件
# 内容如下

[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
use-mirrors =true
mirrors = https://pypi.tuna.tsinghua.edu.cn/simple
trusted-host = pypi.tuna.tsinghua.edu.cn
b. Windows
1
2
3
4
1、文件管理器文件路径地址栏敲:%APPDATA% 回车,快速进入 C:\Users\电脑用户\AppData\Roaming 文件夹中
2、新建 pip 文件夹并在文件夹中新建 pip.ini 配置文件
3、新增 pip.ini 配置文件内容
# 内容如上

github加速

  1. github加速访问

a. 添加hosts

点击寻找合适的ip,不出意外的话大陆都是红色,将香港、台湾、新加坡的IP加入hosts,应该可行。

b. 使用镜像站
  1. https://hub.fastgit.xyz
  2. https://hub.xn--p8jhe.tw
c. 使用steam++、ds、FastGithub
  1. steam++
  2. dev-sidecar
  3. FastGithub
d. 梯子

不介绍

  1. github加速下载

油猴插件加速

Github 增强

Release、Code(ZIP) 文件加速:

使用方法为:前面为代理地址,后面为你想要下载的地址

示例:https://gh.shyi.org/https://github.com/hunshcn/project/archive/master.zip

  1. https://gh.shyi.org
  2. https://gh.api.99988866.xyz
  3. https://gh.gh2233.ml
  4. https://gh2.yanqishui.work
  5. https://gh.ddlc.top

以上使用的是cf work,有些地区打不开

  1. https://ghproxy.com
  2. https://mirror.ghproxy.com
  3. https://download.fastgit.org # 需要将github.com替换成download.fastgit.org
Git Clone 加速:
  1. https://ghproxy.com

  2. https://mirror.ghproxy.com

1
git clone https://ghproxy.com/https://github.com/stilleshan/ServerStatus

git clone 私有仓库

Clone 私有仓库需要用户在 Personal access tokens 申请 Token 配合使用.
git clone https://user:your_token@ghproxy.com/https://github.com/your_name/your_private_repo

  1. https://ghproxy.futils.com
  2. https://gh.shyi.org

npm

一、

npm换源

1
2
3
npm config set registry http://registry.npm.taobao.org/ # 淘宝源
npm i --registry https://registry.npm.taobao.org #淘宝源
npm config set registry https://registry.npmjs.org/ # 官方源

npm设置代理

1
2
3
4
5
6
7
# 设置
npm config set proxy http://server:port
npm config set https-proxy http://server:port

# 取消
npm config delete proxy
npm config delete https-proxy

二、

1
https://npmmirror.com

1.使用 cnpm命令行工具代替默认的 npm

1
npm install -g cnpm --registry=https://registry.npmmirror.com

2.添加 npm 参数 alias 一个新命令

1
2
3
4
5
6
7
8
9
10
alias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npmmirror.com/mirrors/node \
--userconfig=$HOME/.cnpmrc"

# Or alias it in .bashrc or .zshrc
echo '\n#alias for cnpm\nalias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npmmirror.com/mirrors/node \
--userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc

安装模块

1
cnpm install [name]

同步模块

1
2
3
4
# 直接通过 sync 命令马上同步一个模块, 只有 cnpm 命令行才有此功能:
cnpm sync express
# 通过 web 方式来同步: /sync/express
open https://npmmirror.com/sync/express

其他命令

支持 npm 除了 publish 之外的所有命令

1
cnpm info express

gg

https://github.com/mzz2017/gg

gg 是一个命令行工具,可在 Linux 环境下对任意命令进行一键代理,而无需安装 v2ray 等其他工具。

你只需要在想代理的命令之前添加 gg 即可,例如: gg python -m pip install torch.

引用与参考:

清华大学开源软件镜像站 | Tsinghua Open Source Mirror

USTC Open Source Software Mirror

Docker更换国内镜像源 - 憨厚的小怪 - 博客园 (cnblogs.com)

群晖docker镜像源更换为阿里云镜像源_MoFalleaves的博客-CSDN博客_群晖docker源

Ubuntu 更换下载源 - 走看看 (zoukankan.com)

修改Ubuntu系统默认软件下载源_达少Rising的博客-CSDN博客_ubuntu更换下载源

Markdown中如何实现内容折叠操作

python pip更换下载源 (sins7.cn)

切换python的pip源

npmmirror 中国镜像站

Github 增强 - 高速下载

GitHub Proxy

gh-proxy

Mirror List

关于Docker官方镜像仓库被墙的一些解决办法

国内的 Docker Hub 镜像加速器

https://github.com/DaoCloud/public-image-mirror

https://www.oiox.cn/index.php/archives/405/

https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6

https://www.wangdu.site/course/2109.html

https://github.com/mzz2017/gg


镜像源加速下载
https://shyi.org/posts/11367/
作者
Shyi
发布于
2022年5月5日
更新于
2024年9月7日
许可协议