bash – 在带有’source’的Dockerfile中使用RUN指令不起作用
发布时间:2020-12-15 16:47:27 所属栏目:安全 来源:网络整理
导读:我有一个Dockerfile,我安装一个香草python环境(我将安装一个应用程序,但在以后的日期)。 FROM ubuntu:12.04# required to build certain python librariesRUN apt-get install python-dev -y# install pip - canonical installation instructions from pip
我有一个Dockerfile,我安装一个香草python环境(我将安装一个应用程序,但在以后的日期)。
FROM ubuntu:12.04 # required to build certain python libraries RUN apt-get install python-dev -y # install pip - canonical installation instructions from pip-installer.org # http://www.pip-installer.org/en/latest/installing.html ADD https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py /tmp/ez_setup.py ADD https://raw.github.com/pypa/pip/master/contrib/get-pip.py /tmp/get-pip.py RUN python /tmp/ez_setup.py RUN python /tmp/get-pip.py RUN pip install --upgrade pip # install and configure virtualenv RUN pip install virtualenv RUN pip install virtualenvwrapper ENV WORKON_HOME ~/.virtualenvs RUN mkdir -p $WORKON_HOME RUN source /usr/local/bin/virtualenvwrapper.sh 构建运行确定,直到最后一行,其中我得到以下异常: [previous steps 1-9 removed for clarity] ... Successfully installed virtualenvwrapper virtualenv-clone stevedore Cleaning up... ---> 1fc253a8f860 Step 10 : ENV WORKON_HOME ~/.virtualenvs ---> Running in 8b0145d2c80d ---> 0f91a5d96013 Step 11 : RUN mkdir -p $WORKON_HOME ---> Running in 9d2552712ddf ---> 3a87364c7b45 Step 12 : RUN source /usr/local/bin/virtualenvwrapper.sh ---> Running in c13a187261ec /bin/sh: 1: source: not found 如果我进入该目录(只是为了测试以前的步骤提交)我可以看到,文件存在的预期: $ docker run 3a87 ls /usr/local/bin easy_install easy_install-2.7 pip pip-2.7 virtualenv virtualenv-2.7 virtualenv-clone virtualenvwrapper.sh virtualenvwrapper_lazy.sh 如果我试图运行源命令,我得到相同的“未找到”错误,如上所述。但是,如果我运行交互式shell会话,源工作: $ docker run 3a87 bash source bash: line 1: source: filename argument required source: usage: source filename [arguments] 我可以从这里运行脚本,然后愉快地访问workon,mkvirtualenv等。 我做了一些挖掘,最初它看起来好像这个问题可能在于bash作为Ubuntu登录shell和dash作为Ubuntu系统shell之间的区别,dash不支持source命令。 然而,这个答案似乎是使用’。’。而不是源代码,但是这只是导致Docker运行时爆炸了一个go panic异常。 从Dockerfile RUN指令运行shell脚本来解决这个问题(运行Ubuntu 12.04 LTS的默认基本映像)的最好方法是什么。 FROM ubuntu:14.04 RUN rm /bin/sh && ln -s /bin/bash /bin/sh 这应该适用于每个Ubuntu Docker基本映像。我通常为我写的每个Dockerfile添加这一行。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- webservice文件上传下载(byte[] 实现方式)
- twitter-bootstrap – Bootstrap 3个断点和媒体查询
- 自定义bootstrap样式-9行样式自定义漂亮大气bootstrap导航栏
- PDA智能程序访问WebService,报告“未能建立与网络的连接
- 数组 – 如何使用for循环中的值填充数组
- 一步一步封装自己的HtmlHelper组件BootstrapHelper(三)
- Angular Reactive Form-响应式表单验证
- [bootstrap]2.X下的bootstrap-responsive.css相关类已经被3
- AngularJS系列——扩展模块-动画、表单验证、路由
- 使用shell脚本实现自动备份MySQL数据库