Docker错误:使用apk时无法满足的约束

时间:2020-04-18 16:16:30

标签: docker dockerfile docker-image docker-build

我正在使用它作为我的Dockerfile。构建它时,代码存在于步骤2。

FROM python:3.7-alpine
RUN apk update && apk add --no-cache gcc libffi-dev g++ python-dev build-base linux-headers postgresql-dev postgresql-contrib pcre-dev bash alpine-sdk jpeg-dev zlib-dev \ && pip install wheel

COPY ./requirements.txt .

RUN pip install -r requirements.txt

这就是我在终端上得到的

Building web
Step 1/18 : FROM python:3.7-alpine
 ---> 7fbc871584eb
Step 2/18 : RUN apk update && apk add --no-cache gcc libressl libffi-dev g++ python-dev build-base linux-headers postgresql-dev postgresql-contrib pcre-dev bash alpine-sdk jpeg-dev zlib-dev \ && pip install wheel
 ---> Running in 102a327c46d9
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
v3.11.5-56-gd94bd50429 [http://dl-cdn.alpinelinux.org/alpine/v3.11/main]
v3.11.5-54-g70c5111c08 [http://dl-cdn.alpinelinux.org/alpine/v3.11/community]
OK: 11274 distinct packages available
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
   (missing):
    required by: world[]
ERROR: Service 'web' failed to build: The command '/bin/sh -c apk update && apk add --no-cache gcc libressl libffi-dev g++ python-dev build-base linux-headers postgresql-dev postgresql-contrib pcre-dev bash alpine-sdk jpeg-dev zlib-dev \ && pip install wheel' returned a non-zero code: 1

我的Docker版本19.03.3

1 个答案:

答案 0 :(得分:2)

\之前,RUN命令中只包含不必要的pip install wheel。删除它,它将起作用。

RUN apk update && apk add --no-cache gcc libffi-dev g++ python-dev build-base linux-headers postgresql-dev postgresql-contrib pcre-dev bash alpine-sdk jpeg-dev zlib-dev && pip install wheel