Wenn nicht direkt auf das externe Netzwerk zugegriffen werden kann, müssen zusätzlich zu den globalen Proxy-Einstellungen des Hosts separate Proxys für den Docker-Client und die Docker-Instanz festgelegt werden.
Wenn beim Ausführen von Docker Run der folgende Fehler auftritt
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp 3.216.34.172:443: i/o timeout.
See 'docker run --help'.
Sie können die Docker-Warehouse- und Proxy-Konfiguration ändern
Ändern Sie das Docker-Repository
/etc/docker/daemon.json
# vi /etc/docker/daemon.json
# cat daemon.json
{
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"https://hub-mirror.c.163.com",
"https://mirror.baidubce.com"
]
}
Ändern Sie die Proxy-Konfiguration des Docker-Clients
/etc/systemd/system/docker.service.d/proxy.conf
# vi /etc/systemd/system/docker.service.d/proxy.conf
# cat proxy.conf
[Service]
Environment="HTTP_PROXY=http://IP:Port/"
Environment="HTTPS_PROXY=http://IP:Port/"
Environment="NO_PROXY=https://registry-1.docker.io/v2/"
Ändern Sie die Proxy-Konfiguration der Docker-Instanz
~/.docker/config.json
[xxx]# cat ~/.docker/config.json
{
"proxies":
{
"default":
{
"httpProxy": "http://IP:Port/",
"httpsProxy": "http://IP:Port/",
"noProxy": "127.0.0.0/8"
}
}
}
Oder fügen Sie beim Starten von Docker Umgebungsvariablenparameter hinzu
--env HTTP_PROXY="http://IP:Port"
--env HTTPS_PROXY="https://IP:Port"
--env FTP_PROXY="ftp://IP:Port"
--env NO_PROXY="127.0.0.0/8"