[英]Dockerfile RUN command returning “No such file or directory”
Trying to create a Dockerfile to create a system that includes a custom build of Python 3 on a CentOS 7 System. 尝试创建一个Dockerfile来创建一个在CentOS 7系统上包含Python 3自定义构建的系统。 My Dockerfile is as follows: 我的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"]
And its all the way through to the "RUN ./configure --prefix=/usr/local" line and then gives me a "No such file or directory" message. 它一直到“RUN ./configure --prefix = / usr / local”行,然后给我一个“没有这样的文件或目录”的消息。 Snipped: 剪断:
... 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
When I launch container 038c6b892731 into a bash session the "./configure --prefix=/usr/local" command works as expected: 当我将容器038c6b892731发送到bash会话时,“./ 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. ...
I have tried changing the RUN command to "RUN ["./configure","--prefix=/usr/local"]" with the only change in output being the error message being formatted slightly differently. 我尝试将RUN命令更改为“RUN [”./configure","--prefix=/usr/local“]”,输出中的唯一更改是错误消息的格式略有不同。
This is running under: 这是在以下运行:
$ docker -v
Docker version 1.12.2, build bb80604
I run your Dockerfile with the same error. 我运行你的Dockerfile同样的错误。
But when I changed from this: 但是当我改变时:
RUN "./configure --prefix=/usr/local"
to this: 对此:
RUN ./configure --prefix=/usr/local
I still had a problem with RUN "make"
so you also need to change Dockerfile like this: 我仍然遇到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"]
And this works for me. 这对我有用。 Or you can use the way with RUN ["xy","ab"]
like @Rao answered. 或者你可以使用RUN ["xy","ab"]
如@Rao回答。
There are trivial changes in the Dockerfile
as show below: Dockerfile
有一些微小的变化,如下所示:
So, please change below lines 所以,请更改以下行
From: 从:
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"
To: 至:
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"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.