Brian Brian - 1 month ago 9
Python Question

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. My Dockerfile is as follows:

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.
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:

$ 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.

This is running under:

$ docker -v
Docker version 1.12.2, build bb80604

Answer

I run your Dockerfile with the same error.

But when I changed from this:

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

to

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

and also I had problem with RUN "make" so you also need to change to this:

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"]

or you can use the way with RUN ["xy","ab"] like @Rao answered.