镜像和代理
🔋 每次用,每次搜,受不了了,这下我全写上
Powershell
设置代理
shell
$env:HTTP_PROXY='http://127.0.0.1:10809'
$env:HTTPS_PROXY='http://127.0.0.1:10809'
Cmd
设置代理
听句劝
使用 Powershell 而不是 cmd,用过的都说好!
shell
set http_proxy=http://127.0.0.1:10809
set https_proxy=http://127.0.0.1:10809
Pip 使用镜像
文件位置:~/.pip/pip.conf
text
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
其他源:
https://pypi.mirrors.ustc.edu.cn/simple
http://pypi.douban.com/simple/
http://mirrors.aliyun.com/pypi/simple/
Git
设置代理
shell
git config --global https.proxy http://127.0.0.1:10809
git config --global https.proxy https://127.0.0.1:10809
git config --global --unset http.proxy
git config --global --unset https.proxy
Npm,Yarn
软件包
小贴士
能用镜像解决的统统用镜像解决,代理由于 SSL 等原因不是很可靠,可能出现网络问题
镜像都是通用的
代理设置
shell
npm config set proxy http://127.0.0.1:10809
npm config set https-proxy http://127.0.0.1:10809
yarn config set proxy http://127.0.0.1:10809
yarn config set https-proxy http://127.0.0.1:10809
镜像设置
shell
# 获取镜像配置
npm config get registry
yarn config get registry
# 设置镜像
npm config set registry https://registry.npmmirror.com/
yarn config set registry https://registry.npmmirror.com/
text
npm ----- https://registry.npmjs.org/
cnpm ---- http://r.cnpmjs.org/
taobao -- https://registry.npmmirror.com/
nj ------ https://registry.nodejitsu.com/
rednpm -- http://registry.mirror.cqupt.edu.cn
skimdb -- https://skimdb.npmjs.com/registry
yarn ---- https://registry.yarnpkg.com
tencent - https://mirrors.cloud.tencent.com/npm/
使用脚本(Yrm 同理)
shell
nrm ls
nrm use
nrm test [name]
小贴士
如果 nrm ls 不出现 *,可以修改 nrm 目录下 cli.js 第 141 行 && 为 ||
nrm 目录就是 npm 包的全局安装目录,如果你也用 Powershell,可以用以下命令找到:
shell
(Get-Command nrm).source
Electron 下载
仅仅开启镜像不够,必须设置环境变量
shell
# powershell
$env:ELECTRON_MIRROR="https://npmmirror.com/mirrors/electron/"
Github 代理
警告
只支持下载,不支持上传
🥇 ghproxy
格式:[command] https://mirror.ghproxy.com/[repo]
shell
# clone
git clone https://mirror.ghproxy.com/[repo]
# download
wget https://mirror.ghproxy.com/[xxx.zip]
curl -O https://mirror.ghproxy.com/[xxx.zip]
🥇 fastgit(有时有点卡)
shell
# clone
git clone https://hub.fastgit.xyz/author/repo
# download
wget https://download.fastgit.org/A/A/releases/download/1.0/1.0.tar.gz
curl -O https://download.fastgit.org/A/A/releases/download/1.0/1.0.tar.gz
Docker
镜像源
- Linux 配置文件位置
/etc/docker/daemon.json
(默认没有需要创建) - Windows 用 Docker Desktop 设置
INFO
阿里的源需要注册,提供一个自定义地址免费使用
json
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn/",
"https://hub-mirror.c.163.com",
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com",
"https://mirror.ccs.tencentyun.com",
"https://registry.docker-cn.com"
]
}
Docker Proxy
多平台容器镜像代理服务,支持 Docker Hub, GitHub, Google, k8s, Quay 等镜像仓库
简单使用(只是用官方镜像),使用如下地址:
json
{
"registry-mirrors": [
"https://dockerproxy.com"
]
}
高级使用(代理),参考 使用教程
特殊镜像
docker pull
拉取 GCR,GHCR,NGC,QUAY 等开头的域名的 Images 十分缓慢,即使配置了国内的镜像源也是无效的。南京大学镜像站解决了此问题,配置步骤如下:
- 在 daemon.json 文件中添加地址:https://docker.nju.edu.cn/
- 更改拉取的域名,如 ghcr.io => ghcr.nju.edu.cn
支持的域名前缀如下:
- GCR
- GHCR
- NGC
- Quay
参考文章:https://sci.nju.edu.cn/9e/05/c30384a564741/page.htm