如何使用ssh加速docker 镜像

使用条件

  1. 有一台远程的服务器,可以通过 ssh 协议进行登录

原理

拉去镜像的流行通过 ssh 协议,走远程的服务器,可以简单的理解远程服务器是一个代理

具体操作

  1. 建立ssh协议的通道,在本地电脑上运行
  ssh -qTfnN -D 127.0.0.1:8080 -p 23 username@xxx.xxx.xxx.xxx
 

2. 配置docker 代理

修改配置文件 /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]
Environment="HTTP_PROXY=socks5://127.0.0.1:8080"
Environment="HTTPS_PROXY=socks5://127.0.0.1:8080"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"

3. 重新启动 docker

systemctl daemon-reload
systemctl restart docker

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注