docker proxy

参考:https://forums.docker.com/t/docker-pull-results-in-request-canceled-while-waiting-for-connection-client-timeout-exceeded-while-awaiting-headers/73064/7

Previous solution only worked until I reboot my machine. Sigh.

But I’ve found another trick in my linux.

I did force the daemon to run through a proxy before connecting the the docker servers, as the registry-1.docker.io was giving me timeout error and I could not even ping it anymore.

Following this instructions 87 I could fix my problem. And that’s all I did:

1. Create a new directory:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

2. Get a free http proxy from this list 195.

3. Create the file below and paste the http proxy server

# File: /etc/systemd/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=208.123.76.34:8080"
Environment="NO_PROXY=localhost,127.0.0.1"

4. Reload systemd manager configurations:

sudo systemd daemon-reload

5. Restart the Docker’s daemon service:

sudo systemd restart docker

6. Check if it’s working:

docker pull alpine

Now it is working here, but the download speed is slow as it is not connected directly to the server. I googled a lot and I’ve no clue how to fix this another way.

.
Edit: Don’t use a proxy to log in as the connection goes through someone’s pc, they will receive your credentials. Today I removed the http proxy to login, and sometimes the connection is stablished, sometimes it isn’t. My network is slow since the past week. Perhaps that’s the reason?

之前的解决方案只能在重新启动计算机之前起作用。叹。

但是我在我的电脑中找到了另外一个窍门linux

我确实强迫守护程序在连接Docker服务器之前通过代理运行,因为这registry-1.docker.io给了我超时错误,我什至无法对其进行ping操作。

按照此说明87, 我可以解决我的问题。这就是我所做的一切:

1.创建一个新目录:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

2.从此列表195 获得免费的http代理

3.在下面创建文件并粘贴http代理服务器

# File: /etc/systemd/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=208.123.76.34:8080"
Environment="NO_PROXY=localhost,127.0.0.1"

4.重新加载systemd Manager配置:

sudo systemd daemon-reload

5.重新启动Docker的守护程序服务:

sudo systemd restart docker

6.检查它是否正常工作:

docker pull alpine

现在它可以在这里工作,但是下载速度很慢,因为它没有直接连接到服务器。我在Google上搜索了很多,但不知道如何以其他方式解决这个问题。


Edit:当连接通过某人的PC时,请勿使用代理进行登录,否则他们会收到您的凭据。今天,我删除了HTTP代理进行登录,有时建立了连接,有时没有建立连接。自上周以来,我的网络运行缓慢。也许那是原因吗?

tail /etc/profile -n4
#export all_proxy=all://192.168.2.1:31280
export HTTP_PROXY=http://192.168.2.1:31280
export HTTPS_PROXY=http://192.168.2.1:31280

grep -C 8 Service /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
Environment="HTTP_PROXY=http://192.168.2.1:31280"
Environment="HTTPS_PROXY=http://192.168.2.1:31280"
Environment="NO_PROXY=localhost,127.0.0.1"

原文地址:https://www.cnblogs.com/BillyLV/p/12311885.html