gpt4 book ai didi

docker 容器中的 Python

转载 作者:太空宇宙 更新时间:2023-11-04 03:19:43 25 4
gpt4 key购买 nike

我是 Docker 的新手,所以很抱歉回答这么简单的问题。

我正在构建一个基于 ubuntu:vivid 图像构建的图像之上的 docker 容器。在容器中执行我的脚本时出现错误:

exec: "python": executable file not found in $PATH

我该如何解决这个问题?当我尝试在我的 Docker 文件中运行 apt-get install python 时:

FROM my_image # based on ubuntu:vivid

RUN apt-get update && \
apt-get install -y python3

ENV PATH /:$PATH

COPY file.py /

CMD ["python", "file.py", "-h"]

我得到:

WARNING: The following packages cannot be authenticated!
libexpat1 libffi6 libmagic1 libmpdec2 libssl1.0.0 libpython3.4-minimal
mime-support libsqlite3-0 libpython3.4-stdlib python3.4-minimal
python3-minimal python3.4 libpython3-stdlib dh-python python3 file
E: There are problems and -y was used without --force-yes
The command '/bin/sh -c apt-get update && apt-get install -y python3' returned a non-zero code: 100
make: *** [image] Error 1

编辑:添加了 Dockerfile 内容

最佳答案

您在使用某些 Linux 发行版时遇到了类似的问题:“Why am I getting authentication errors for packages from an Ubuntu repository?

在所有情况下,安装新包的通常命令顺序是:

RUN apt-get update -yq && apt-get install -yqq \
git \
python \
...

OP Ela报道 in the comments :

RUN apt-get update -y && apt-get install -y --force-yes \
git \
python \
...

关于docker 容器中的 Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35052659/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com