简体   繁体   English

Dockerfile:安装软件包以运行python3脚本

[英]Dockerfile : Install packages to run python3 script

I'm new to Docker (Community Edition) and currently trying to create a Dockerfile to run my python3 script but I'm encountering a problem when I try to build the image 我是Docker(Community Edition)的新手,目前正在尝试创建一个Dockerfile来运行我的python3脚本,但是在尝试构建映像时遇到了问题

Here's my Dockerfile: 这是我的Dockerfile:

FROM python:3

COPY . /

RUN \
apt-get update \
apt-get install python3-pip \
pip3 install bs4 \
pip3 install requests \
apt-get install python3-lxml -y \
pip3 install Pillow \
apt-get install libopenjp2-7 -y \
apt-get install libtiff5 -y

CMD [ "python3","./Manga-Alert.py" ]

But I'm getting an error, he doesn't find the package python3-pip And then fails completely: 但是我遇到一个错误,他没有找到包python3-pip,然后完全失败:

在此处输入图片说明

I'm probably writing my Dockerfile wrongly but I don't know how to resolve my problem. 我可能写错了我的Dockerfile,但是我不知道如何解决我的问题。

Those slashes just mean new line in the docker file. 这些斜线仅表示docker文件中的新行。 It isn't the same as running the commands on the terminal. 这与在终端上运行命令不同。 Because of this you need to separate each command with an && if you want them all to execute under one RUN direction. 因此,如果希望所有命令都在一个RUN方向上执行,则需要用&&分隔每个命令。

FROM python:3

COPY . /

RUN \
apt-get update -y && \
apt-get install python3-pip -y && \
pip3 install bs4 && \
pip3 install requests && \
apt-get install python3-lxml -y && \
pip3 install Pillow && \
apt-get install libopenjp2-7 -y && \
apt-get install libtiff5 -y

CMD [ "python3","./Manga-Alert.py" ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM