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

Windows环境下Cookiecutter Django初始docker-compose构建失败求助

Docker构建Cookiecutter-Django项目失败的解决办法

问题分析

报错exit code: 100是apt-get update或安装包时网络访问失败导致的,大概率是默认软件源访问不畅,或是Windows下Docker的网络配置有问题。

具体解决方案

1. 替换国内软件源

找到项目中对应服务的Dockerfile(一般是web服务的Dockerfile),把apt-get update && apt-get install...那段替换成带国内源的命令:

Debian镜像用阿里云源:

RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    sed -i 's/security.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list && \
    apt-get update && apt-get install --no-install-recommends -y build-essential libpq-dev

Ubuntu镜像用清华源:

RUN sed -i 's/archive.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    sed -i 's/security.ubuntu.com/mirrors.tuna.tsinghua.edu.cn/g' /etc/apt/sources.list && \
    apt-get update && apt-get install --no-install-recommends -y build-essential libpq-dev

2. 调整Docker网络配置

  • 打开Docker Desktop,进入「Settings > Resources > Network」
  • 试试切换WSL2/Hyper-V模式(勾掉或勾选「Use the WSL 2 based engine」)
  • 重启Docker后重新执行构建:docker-compose -f local.yml build

3. 清理Docker缓存再构建

缓存的旧源信息可能拖后腿,先清缓存再重新构建:

docker system prune -af
docker-compose -f local.yml build --no-cache

4. 配置代理(如果你的机器用代理上网)

  • 在Docker Desktop的「Settings > Resources > Proxies」里手动填入代理地址和端口
  • 或者在local.yml的服务配置里加代理环境变量:
services:
  web:
    environment:
      - HTTP_PROXY=http://你的代理地址:端口
      - HTTPS_PROXY=http://你的代理地址:端口
      - NO_PROXY=localhost,127.0.0.1

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 06:08:25