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

使用Anaconda作为Docker父镜像构建时遇连接超时错误,求解决

Fixing Docker Build Timeout When Using Anaconda Base Image

Hey there! Let's break down what's going wrong here and get your Docker build working with Anaconda. First off, let's clear up a couple of things:

First, a Quick Fix to Your Dockerfile

Wait, the FROM line you wrote (continuumio:anaconda3) has a tiny mistake. The official Anaconda image from Continuum is actually named continuumio/anaconda3 (note the slash separating the repository and image name). That's a common typo, but your main issue right now is the network timeout—so let's tackle that first.

Why You're Seeing That Timeout Error

The error message you got:

Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

This isn't about your FROM statement being invalid—it means Docker can't connect to Docker Hub (the official image registry) to pull the Anaconda image. Your network is either too slow, blocked by a firewall/proxy, or having DNS resolution issues.

Steps to Fix It

1. Check Your Basic Network Connection

First, test if your machine can even reach Docker Hub. Run this in your terminal:

curl https://registry-1.docker.io/v2/

If you get a response like {"errors":[{"code":"UNAUTHORIZED","message":"authentication required",...}, that's good—it means your network can connect (you don't need auth for public images, this just confirms the connection works). If it times out, you've got a network block or DNS problem.

For DNS issues: Try adding a public DNS (like 8.8.8.8 or 114.114.114.114) to Docker's settings. On Linux, edit /etc/docker/daemon.json to include:

{ "dns": ["8.8.8.8", "114.114.114.114"] }

Then restart Docker with sudo systemctl restart docker. On Docker Desktop, you can set this in the "Settings" > "Docker Engine" menu.

2. Use a Domestic Image Accelerator (Game-Changer for Slow Regions)

Docker Hub is often slow or unreliable from certain regions. Adding a domestic mirror will speed things up a ton. Here's how:

  • Edit /etc/docker/daemon.json (create it if it doesn't exist) and add these mirrors:
    {
      "registry-mirrors": [
        "https://hub-mirror.c.163.com",
        "https://mirror.aliyuncs.com",
        "https://docker.mirrors.ustc.edu.cn"
      ]
    }
    
  • Restart Docker, then try building again. This should cut down on timeouts drastically.

3. Manually Pull the Anaconda Image First

If the build still fails, pull the image directly to your local machine first—then Docker won't need to fetch it during build:

docker pull continuumio/anaconda3:latest

Once that's done, make sure your Dockerfile uses the correct FROM line:

FROM continuumio/anaconda3:latest

You can also replace latest with a specific version (like 2023.09-0) if you need a stable release.

4. Check for Proxy/Firewall Blocks

If you're on a work or school network, there might be a proxy or firewall blocking Docker Hub. You'll need to configure Docker to use your network's proxy settings. On Docker Desktop, go to "Settings" > "Resources" > "Proxies" and enter your proxy details. On Linux, add proxy settings to /etc/docker/daemon.json as well.

Test It Out

After making these changes, run your build command again:

docker build -t your-anaconda-app .

This should now pull the Anaconda image (or use your local copy) and proceed with the build.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.27 04:01:50