CentOS配置代理并配置Docker代理

自从今年封了Docker镜像后,想下个镜像就很麻烦,所以记录下代理的配置

代理仓库:https://github.com/MetaCubeX/mihomo

安装

启动

如果CentOS装了GUI可以试试这个 mihomo-party,亲测可行,之前在Ubuntu、Debain等试的其他的都各自问题启动不了

其他

  • 之前只是看官方文档,结果文档有点不友好,后面在网上搜索才找到解决方法,还是要转变思路,不要只看官方文档

配置Docker(针对docker pull 因为其被systemd接管 https://docs.docker.com/engine/daemon/proxy/#httphttps-proxy

修改 /lib/systemd/system/docker.service,在[Service]下添加

Environment=”HTTP_PROXY=127.0.0.1:7890″

Environment=”HTTPS_PROXY=127.0.0.1:7890″

刷新并重启

systemctl daemon-reload

systemctl restart docker

查看docker信息

docker info

对于k8s,如果使用的containerd,使用下面的配置

https://stackoverflow.com/questions/77318225/how-to-configure-proxy-in-kubernetes-to-pull-images

Run on terminal:

sudo mkdir -p /etc/systemd/system/containerd.service.d
sudo touch /etc/systemd/system/containerd.service.d/http-proxy.conf
vim /etc/systemd/system/containerd.service.d/http-proxy.conf

Copy and paste into the http-proxy.conf:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com"
Environment="HTTPS_PROXY=http://proxy.example.com"
Environment="NO_PROXY=localhost"

Then restart containerd service:

sudo systemctl daemon-reload
sudo systemctl restart containerd
sudo systemctl show --property=Environment containerd

Leave a Reply

Your email address will not be published. Required fields are marked *

lWoHvYe 无悔,专一