You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu 17.10虚拟机Docker 18.04.0-ce代理环境下登录Docker Hub失败求助

Fixing Docker Login Timeout in Proxy Environment (Ubuntu 17.10 + Docker 18.04.0-ce)

Hey there, I’ve dealt with this exact proxy-related Docker login issue before, so let me break down the fixes that worked for me. That timeout error happens because Docker doesn’t automatically inherit your system’s proxy settings—you need to configure it explicitly for the Docker daemon to use your proxy.

Step 1: Create Docker Daemon Proxy Configuration

First, we’ll set up a dedicated config file for Docker’s proxy settings:

  • Create the systemd service directory for Docker if it doesn’t exist:
    sudo mkdir -p /etc/systemd/system/docker.service.d
    
  • Create a proxy config file (name it http-proxy.conf):
    sudo nano /etc/systemd/system/docker.service.d/http-proxy.conf
    
  • Paste the following content, replacing your-proxy-ip and port with your actual proxy details. If your proxy requires authentication, add your credentials like user:password@ before the proxy IP:
    [Service]
    Environment="HTTP_PROXY=http://your-proxy-ip:port/"
    Environment="HTTPS_PROXY=http://your-proxy-ip:port/"
    Environment="NO_PROXY=localhost,127.0.0.1,192.168.0.0/16"
    
    The NO_PROXY line excludes local addresses and private networks from using the proxy—this prevents issues with local Docker containers and services.

Step 2: Apply the Configuration

After saving the file, reload the systemd daemon and restart Docker to make the changes take effect:

sudo systemctl daemon-reload
sudo systemctl restart docker

Step 3: Verify the Proxy Setup

Check if Docker has picked up the proxy settings by running:

docker info

Scroll down to the Proxy Settings section—you should see your HTTP/HTTPS proxy listed here.

Step 4: Test Connectivity to Docker Hub

Before trying to log in again, test if the proxy can reach Docker Hub with curl:

curl -x http://your-proxy-ip:port https://registry-1.docker.io/v2/

A 401 Unauthorized response is normal here (it just means you haven’t authenticated yet). If you still get a timeout, double-check your proxy address, port, and credentials—there might be a network issue with your proxy server itself.

Final Step: Try Docker Login Again

Now run your login command again:

docker login -u <username> -p <cool password>

It should connect successfully to Docker Hub this time.

内容的提问来源于stack exchange,提问作者KALALEX

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.26 08:47:20