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

Docker代理服务器配置求助:运行hello-world时连接镜像仓库超时

Fixing Docker Proxy Configuration to Resolve Registry Connection Timeouts

Got it, let's fix this proxy issue so you can pull the hello-world image without those timeout errors. The problem is Docker isn't using your network proxy to reach Docker Hub, so we need to configure Docker to route its requests through your proxy server. Here's how to do it based on your operating system:

Linux Systems

  1. First, create the directory for Docker service configuration overrides:
    sudo mkdir -p /etc/systemd/system/docker.service.d
    
  2. Create a proxy configuration file named http-proxy.conf with your proxy details:
    [Service]
    Environment="HTTP_PROXY=http://your-proxy-address:port/"
    Environment="HTTPS_PROXY=http://your-proxy-address:port/"
    Environment="NO_PROXY=localhost,127.0.0.1,192.168.0.0/16"
    
    Replace your-proxy-address:port with your actual proxy server details. The NO_PROXY line lists addresses that don't need to go through the proxy (adjust this to include any local or private registry addresses you use).
  3. Reload the systemd daemon to pick up the new configuration:
    sudo systemctl daemon-reload
    
  4. Restart Docker to apply the proxy settings:
    sudo systemctl restart docker
    
  5. Verify the proxy is set correctly by running:
    docker info | grep -A 2 "Proxy"
    
    You should see your proxy addresses listed here.

Windows Systems (Docker Desktop)

  1. Open Docker Desktop and click the gear icon (Settings) in the top-right corner.
  2. Navigate to Resources → Proxies.
  3. Select Manual proxy configuration.
  4. Enter your proxy details in the HTTP Proxy and HTTPS Proxy fields (format: http://proxy-address:port).
  5. Add any local or internal addresses to the No proxy field (e.g., localhost,127.0.0.1).
  6. Click Apply & Restart to save the settings and restart Docker.

macOS Systems (Docker Desktop)

  1. Click the Docker icon in your top menu bar and select Preferences.
  2. Go to Resources → Proxies.
  3. Choose Manual proxy configuration.
  4. Input your HTTP and HTTPS proxy addresses in the respective fields.
  5. Add excluded hosts (local addresses, private registries) to the Exclude hosts box.
  6. Click Apply & Restart to activate the proxy settings.

Bonus: Docker Compose Proxy Settings

If you need proxy settings specifically for Docker Compose (though the global Docker config should cover this), you can create a .env file in your Compose project directory with:

HTTP_PROXY=http://your-proxy-address:port/
HTTPS_PROXY=http://your-proxy-address:port/
NO_PROXY=localhost,127.0.0.1

Compose will automatically use these environment variables when running services.

Once you've completed the configuration, test it out by running:

docker run hello-world

This should now successfully pull the image and run the test container.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.12 03:46:07