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

运行docker-compose up遭遇构建错误,该如何解决?

解决Docker构建中peewee安装失败的问题

问题重现

执行docker-compose up时触发构建失败,核心错误信息:

Command "/usr/local/bin/python /usr/local/lib/python3.6/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmpefh9j7q8" failed with error code 1 in /tmp/pip-install-iv15vhai/peewee
failed to solve: process "/bin/sh -c pip install -r requirements.txt" did not complete successfully: exit code: 1

已尝试升级pip但问题未解决,当前使用的Dockerfile基于python:3.6-alpine3.6。

问题原因

  1. pip升级顺序错误:原Dockerfile先安装依赖再升级pip,导致安装peewee时使用的仍是老版本pip(19.0.1),老版本pip对PEP517构建流程支持不完善。
  2. Python版本兼容性:Python3.6已停止维护,高版本pip(如21.3.1)对其兼容性有限,同时新版peewee可能不再支持Python3.6。
  3. Alpine编译依赖缺失:Alpine使用musl libc,编译Python原生扩展时可能缺少musl-dev这类基础编译依赖。

解决方案

1. 调整Dockerfile中的pip升级顺序

将pip升级步骤移到安装requirements之前,确保安装依赖时使用的是新版pip:

# Use an official Python runtime as a parent image
FROM python:3.6-alpine3.6

# Set the working directory to /src
WORKDIR /src

# Copy the current directory contents into the container at /src
COPY requirements.txt /src/

# Install any needed packages specified in requirements.txt 
RUN apk update && \
    apk add --no-cache ffmpeg make automake gcc g++ subversion \
    sqlite-dev libffi-dev openssl-dev musl-dev && \
    # 先升级pip到支持Python3.6的最高版本
    pip install --no-cache-dir pip==21.3.1 && \
    pip install --no-cache-dir -r requirements.txt

2. 锁定peewee兼容Python3.6的版本

如果你的requirements.txt中未指定peewee版本,或版本过高,修改为Python3.6兼容的版本:

# 在requirements.txt中添加版本限制
peewee<=3.14.10

3. 重新构建验证

执行以下命令清理缓存并重新构建:

docker-compose build --no-cache
docker-compose up

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.03 20:00:05