[英]Error while building Docker: "Package 'mongodb' has no installation csndidate" with python:3.7 image
我正在尝试使用 docker 构建此 docker 图像:
FROM python:3.7-slim
# Keeps Python from generating .pyc files in the container
ENV PYTHONDONTWRITEBYTECODE=1
# Turns off buffering for easier container logging
ENV PYTHONUNBUFFERED=1
RUN apt-get update && apt-get install -y \
build-essential \
make \
gcc \
python3-dev \
mongodb
# Create working directory and copy all files
COPY . /app
WORKDIR /app
# Pip install requirements
RUN pip install --user -r requirements.txt
# Port to expose
EXPOSE 8000
# During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
CMD ["python", "main.py", "runserver"]
但我收到此错误:
Package 'mongodb' has no installation candidate
当我使用python:3.4-slim
运行相同的 docker 图像时,它可以工作。 为什么?
That's because python:3.4-slim
uses Debian stretch (9) for its base and the mongodb
package is available in its repos. 但是对于python:3.7-slim
,基础是靶心 (11) 并且 mongodb 不再在其存储库中。
我建议不要在上面构建的映像中安装 mongodb,而是使用单独的 mongodb 容器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.