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

构建Docker镜像时出现请求取消超时错误,寻求解决方案

解决Docker拉取镜像时的超时/连接取消问题

Hey there, let's tackle this Docker registry connection issue you're facing. Those timeout errors when pulling ubuntu:14.04 are super common when there's network latency or registry access roadblocks. Here are some tried-and-true fixes to get you back on track:

  • 检查基础网络连通性
    First things first: make sure your machine can reach the outside world. Run a quick ping test to confirm:

    ping google.com
    

    If that fails, your core network connection is the problem—sort that out first. If it works, test connectivity to Docker's registry port directly:

    telnet registry-1.docker.io 443
    

    If telnet can't connect, odds are a firewall or network policy is blocking port 443. You'll need to adjust those settings or check with your network admin.

  • 延长Docker的超时时间
    Docker's default timeout might be too short for slow networks. Tweak the daemon config to give it more breathing room:

    1. Edit (or create) the /etc/docker/daemon.json file and add this:
      {
        "timeout": 300
      }
      
      This sets the timeout to 300 seconds (5 minutes)—plenty of time for slow pulls.
    2. Restart Docker to apply the change:
      sudo systemctl restart docker
      

    Try building your image again after this.

  • 切换到国内镜像源
    Connecting to Docker's official registry from some regions can be painfully slow. Swap in a local mirror to speed things up:

    1. Update /etc/docker/daemon.json with mirror addresses (pick one or more that work for you):
      {
        "registry-mirrors": [
          "https://hub-mirror.c.163.com",
          "https://mirror.baidubce.com"
        ]
      }
      
    2. Restart Docker, then try pulling the image again. You should see a noticeable speed boost.
  • 配置Docker代理设置
    If you're behind a corporate proxy, Docker might not be using it correctly, leading to connection drops. Configure the daemon to use your proxy:

    1. Create a proxy config file at /etc/systemd/system/docker.service.d/http-proxy.conf with these lines (replace with your actual proxy details):
      [Service]
      Environment="HTTP_PROXY=http://your-proxy-host:port/"
      Environment="HTTPS_PROXY=http://your-proxy-host:port/"
      Environment="NO_PROXY=localhost,127.0.0.1"
      
    2. Reload systemd and restart Docker:
      sudo systemctl daemon-reload
      sudo systemctl restart docker
      
  • 换个网络测试
    If you're on a restricted network (like a company VPN), try switching to an unrestricted one (e.g., your phone's hotspot). Sometimes corporate firewalls block access to Docker's registry, and this quick test will confirm if that's the root cause.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:55:25