我是 ubuntu 新手,我正在尝试使用 dockerfile 在 ubuntu 16.04 中创建 docker 映像。
Dockerfile:
FROM ubuntu:16.04
MAINTAINER bill <bill@gmailcom>
RUN apt-get update
RUN apt-get install -y dh-python
RUN apt-get install -y python3 python3-pip
RUN apt-get install -y bcrypt
RUN pip3 install flask pymongo flask_bcrypt
RUN pip3 install Flask-PyMongo py-bcrypt
RUN mkdir /app
RUN mkdir -p /app/templates
COPY webservice.py /app/webservice.py
ADD templates /app/templates
EXPOSE 5000
WORKDIR /app
ENTRYPOINT ["python3" , "-u" , "webservice.py" ]
添加这一行 RUN apt-get install -y dh-python
是因为一开始我会得到错误
Package python3 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
However the following packages replace it:
dh-python
E: Package 'python3' has no installation candidate
The command '/bin/sh -c apt-get install -y python3 python3-pip' returned a non-zero code: 100
但是在尝试再次构建我的图像后,我收到了一个新的错误:
The following packages have unmet dependencies: dh-python : Depends: python3:any (>= 3.3.2-2~) but it is not installable E: Unable to correct problems, you have held broken packages. The command '/bin/sh -c apt-get install dh-python' returned a non-zero code: 100
我将默认 Python 版本从 2.7 更改为 3.6.9,但仍然出现相同的错误。如果您能帮助我解决这个问题,我将不胜感激。提前谢谢您
答案1
解决方案:删除所有退出的容器并从 dockerfile 中删除 dh-python 安装,然后就可以了