Dockerfile RUN命令返回"没有这样的文件或目录"

时间:2016-10-21 17:04:53

标签: python docker build dockerfile

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

 # Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
   GOOGLE_APP_ID=1:my:app:id

   # Replace the /Path/To/ServiceAccount.json with the path to the key you just downloaded
   "${PODS_ROOT}"/FirebaseCrash/upload-sym "/Path/To/ServiceAccount.json"

一直到" RUN ./configure --prefix = / usr / local"然后给我一个"没有这样的文件或目录"信息。 剪断:

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

当我将容器038c6b892731发送到bash会话时," ./ 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

我尝试将RUN命令更改为" RUN [" ./ 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. ...

2 个答案:

答案 0 :(得分:2)

我使用相同的错误运行 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回答。

答案 1 :(得分:0)

Dockerfile中有一些微不足道的变化,如下所示:

因此,请更改以下行 来自:

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"

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