作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
尝试创建 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/
我是一名优秀的程序员,十分优秀!