镜像与代理
镜像
Docker
2024-06-06:上海交大中止对 dockerhub 仓库的镜像,链接。
阿里云的源也无法使用:仅限阿里云用户通过支持公网访问的阿里云产品上使用该镜像加速能力。也就是说阿里云镜像加速只能在他们的产品上使用。
腾讯云的源:
bash
cat <<EOF>> /etc/docker/daemon.json
{
"registry-mirrors": ["https://mirror.ccs.tencentyun.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Python
临时使用
bash
pip3 install 软件名 -i https://mirrors.aliyun.com/pypi/simple/
永久使用
bash
cat <<EOF>> ~/.pip/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
EOF
Ubuntu
18.04(bionic)
先备份系统原有的源配置文件
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
再执行如下操作
cat <<EOF>> /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
EOF
然后执行sudo apt-get update
更新软件源列表即可。
NPM
临时使用
bash
npm --registry http://registry.npmmirror.com install 软件名
永久使用
bash
npm config set registry http://registry.npmmirror.com
http://npm.taobao.org
和 http://registry.npm.taobao.org
在 2022.06.30 号正式下线和停止 DNS 解析。
新域名为 npmmirror.com, 相关服务域名切换规则请参考:
http://npm.taobao.org => http://npmmirror.com
http://registry.npm.taobao.org => http://registry.npmmirror.com
检查是否配置成功:npm config get registry
Yarn
临时使用
bash
yarn save 软件名 --registry http://registry.npmmirror.com
永久使用
bash
yarn config set registry http://registry.npmmirror.com
代理
终端代理
Linux终端命令,端口要进行适当修改。
bash
export https_proxy=http://127.0.0.1:7890 http_proxy=http://127.0.0.1:7890 all_proxy=socks5://127.0.0.1:7890
Windows CMD终端命令,端口要进行适当修改。不适用于PowerShell。
bash
set http_proxy=http://10.211.55.2:7890
set https_proxy=http://10.211.55.2:7890
set all_proxy=socks5://10.211.55.2:7890
Dockerfile代理
在Dockerfile前面加上
Dockerfile
ENV https_proxy=http://127.0.0.1:7890
ENV http_proxy=http://127.0.0.1:7890
ENV all_proxy=socks5://127.0.0.1:7890
在最后要将这三个环境变量清除
Dockerfile
ENV https_proxy=""
ENV http_proxy=""
ENV all_proxy=""