错误:约束无法满足-Docker

时间:2018-08-11 09:32:55

标签: python docker

当我安装Python项目时,出现Docker错误。尽管在google上进行了研究,但我没有找到解决方案。顺便说一下,当我在Docker上运行项目时,如何在浏览器上显示?

test@test-VirtualBox:~/backend$ sudo docker build  -t test .
Sending build context to Docker daemon  489kB
Step 1/11 : FROM python:3.6-alpine
 ---> 267db919e15e
Step 2/11 : RUN addgroup -S app && adduser -S -g app app
 ---> Using cache
 ---> ce1632a22469
Step 3/11 : WORKDIR /usr/src/app
 ---> Using cache
 ---> 01b36ea9b7c1
Step 4/11 : RUN apk --update --upgrade add --virtual deps       gcc python3-dev linux-headers musl-dev      alpine-sdk openssl-dev gmp-dev libffi-dev       postgresql-dev &&   apk --update --upgrade add --no-cache libpq gmp
 ---> Running in d962dfc4a26a
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: unsatisfiable constraints:
  openssl-dev-1.0.2o-r2:
    conflicts:
            libressl-dev-2.7.4-r0[pc:libcrypto=1.0.2o]
            libressl-dev-2.7.4-r0[pc:libssl=1.0.2o]
            libressl-dev-2.7.4-r0[pc:openssl=1.0.2o]
  libressl-dev-2.7.4-r0:
    conflicts:
            openssl-dev-1.0.2o-r2[pc:libcrypto=2.7.4]
            openssl-dev-1.0.2o-r2[pc:libssl=2.7.4]
            openssl-dev-1.0.2o-r2[pc:openssl=2.7.4]
    satisfies:
            postgresql-dev-10.5-r0[libressl-dev]
  deps-0:
    masked in: cache
    satisfies: world[deps]
The command '/bin/sh -c apk --update --upgrade add --virtual deps       gcc python3-dev linux-headers musl-dev      alpine-sdk openssl-dev gmp-dev libffi-dev       postgresql-dev &&   apk --update --upgrade add --no-cache libpq gmp' returned a non-zero code: 4

Dockerfile:

FROM python:3.6-alpine

RUN addgroup -S app && adduser -S -g app app
WORKDIR /usr/src/app

RUN apk --update --upgrade add --virtual deps \
      gcc python3-dev linux-headers musl-dev \
      alpine-sdk gmp-dev libffi-dev \
      postgresql-dev && \
    apk --update --upgrade add --no-cache libpq gmp

COPY ./requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt
RUN apk del deps

COPY . /usr/src/app
RUN chown -R app:app /usr/src/app

USER app

EXPOSE 8080

2 个答案:

答案 0 :(得分:4)

为什么需要安装$sql = "select * from store where cat = laptop; 软件包?高山软件包使用openssl-dev进行编译。您无法在装有Alphine 3.6的容器中同时安装libresslopenssl-dev

答案 1 :(得分:0)

我遇到了同样的问题。我们公司基于python:2.7-alpine构建了基本图片,但是它可能太旧了。因此,仅安装openssl-dev是不够的。

看这个:

satisfies:
            postgresql-dev-10.5-r0[libressl-dev]

postgresql-dev依赖于libressl-dev,因此我首先删除openssl-dev:

RUN apk del openssl-dev

那一切都很好。