gpt4 book ai didi

python - Dockerfile RUN 命令返回 "No such file or directory"

转载 作者:行者123 更新时间:2023-11-30 22:48:25 26 4
gpt4 key购买 nike

尝试创建 Dockerfile 以创建一个包含 CentOS 7 系统上的 Python 3 自定义构建的系统。我的 Dockerfile 如下:

FROM centos:7

RUN yum -y update
RUN yum -y upgrade
RUN yum -y groupinstall "Development Tools"
RUN yum -y install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel
ADD http://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz Python-3.5.2.tgz

RUN ["tar","zxf","Python-3.5.2.tgz"]
WORKDIR "/Python-3.5.2"
RUN "./configure --prefix=/usr/local"
RUN "make"
RUN "make altinstall"
RUN ["rm","-rf","Python-3.5.2"]

RUN yum -y clean headers &&\
yum -y clean packages &&\
yum -y clean metadata

COPY pack/*.py /usr/src/StorageService/

RUN ["/usr/local/bin/pip3.5","install","virtualenv"]
WORKDIR "/usr/src/StorageService"
RUN ["virtualenv","--python=python3","--always-copy","SSEnv"]
RUN ["source","SSEnv/bin/activate"]
RUN ["/usr/local/bin/pip3.5","install","requests"]
RUN ["/usr/local/bin/pip3.5","install","gunicorn"]

CMD ["gunicorn","--bind=5000","app"]

它一直到“RUN ./configure --prefix=/usr/local”行,然后给我一条“没有这样的文件或目录”消息。截图:

... previous steps etc. ...
Step 8 : RUN tar zxf Python-3.5.2.tgz
---> Running in 40f96306f38a
---> 95804837192a
Removing intermediate container 40f96306f38a
Step 9 : WORKDIR "/Python-3.5.2"
---> Running in d8cff5664038
---> 038c6b892731
Removing intermediate container d8cff5664038
Step 10 : RUN "./configure --prefix=/usr/local"
---> Running in 49b410bed643
/bin/sh: ./configure --prefix=/usr/local: No such file or directory
The command '/bin/sh -c "./configure --prefix=/usr/local"' returned a non-zero code: 127

当我将容器 038c6b892731 启动到 bash session 中时,“./configure --prefix=/usr/local”命令按预期工作:

$ docker run -it 038c6b892731 bash
[root@3aeaea02fede Python-3.5.2]# ./configure --prefix=/usr/local
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
... etc. ...

我尝试将 RUN 命令更改为“RUN [”./configure”,”--prefix=/usr/local”]”,输出中唯一的变化是错误消息的格式略有不同。

它运行在:

$ docker -v
Docker version 1.12.2, build bb80604

最佳答案

我运行你的Dockerfile,但出现同样的错误。

但是当我从此改变时:

     RUN "./configure --prefix=/usr/local"

对此:

     RUN ./configure --prefix=/usr/local

我仍然遇到 RUN "make" 问题,因此您还需要像这样更改 Dockerfile:

RUN ["tar","zxf","Python-3.5.2.tgz"]
WORKDIR "/Python-3.5.2"
RUN ./configure --prefix=/usr/local
# changed
RUN make
# changed
RUN make altinstall
RUN ["rm","-rf","Python-3.5.2"]

这对我有用。或者您可以使用 RUN ["xy","ab"] 的方式,就像 @Rao 回答的那样。

关于python - Dockerfile RUN 命令返回 "No such file or directory",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40182038/

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