在学习和工作环境中我们如果需要在服务器上使用科学上网,可以使用我总结的一个方法

1. Clash for Linux

这个在github上的一个开源项目

https://github.com/nelvko/clash-for-linux-install

2. 使用

--- 1. 安装clash
cd clash-for-linux-install 
install.sh

--- 2. 订阅地址
--- 3. 开启代理
 clashctl --help

3. docker 拉取镜像

开启代理后我们发现可以ping通谷歌了,我们需要使用docker 来拉取docker hub的镜像,发现还拉取不了。这时候可以开启TUN模式,如果TUN模式无法开启的话可以使用守护进程代理(我使用的)

mkdir -p /etc/systemd/system/docker.service.d
tee /etc/systemd/system/docker.service.d/proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1,::1"
EOF

systemctl daemon-reload
systemctl restart docker

这样 Docker 直接通过 Clash 的 HTTP 代理访问外网,
不依赖内核,不用开 TUN,也最稳定。