我有一个Dockerfile,我正在整理它来安装一个vanilla 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
Run Code Online (Sandbox Code Playgroud)
构建运行正常,直到最后一行,我得到以下异常:
[previous steps 1-9 removed for clarity]
...
Successfully installed virtualenvwrapper virtualenv-clone stevedore …Run Code Online (Sandbox Code Playgroud) 我想这是一个环境问题.当我手动执行它(没有Dockerfile)时,它可以工作.
这是我的Dockerfile:
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get upgrade --assume-yes
RUN apt-get install wget vim git --assume-yes
# install RVM
RUN apt-get install build-essential curl --assume-yes
RUN curl -L https://get.rvm.io | bash -s stable
RUN echo 'source /etc/profile.d/rvm.sh' >> ~/.bashrc
RUN /usr/local/rvm/bin/rvm-shell -c "rvm requirements"
# install Ruby
RUN /usr/local/rvm/bin/rvm-shell -c "rvm autolibs enable"
RUN /usr/local/rvm/bin/rvm-shell -c "rvm install 2.1.2"
# install Rails
RUN echo "gem: --no-rdoc --no-ri" >> ~/.gemrc
RUN gem install rails -v 4.1.5
# install nodeJS …Run Code Online (Sandbox Code Playgroud) 我已经搜索了一些问题,例如docker ENV vs RUN export,它解释了这些命令之间的差异,但是并没有帮助解决我的问题。
例如,我有一个名为的脚本myscript:
#!/bin/bash
export PLATFORM_HOME="$(pwd)"
Run Code Online (Sandbox Code Playgroud)
并在Dockerfile中包含以下几行:
...
COPY myscript.sh /
RUN ./myscript.sh
Run Code Online (Sandbox Code Playgroud)
我也尝试在调用脚本之前使用ENTRYPOINT而不是RUN或声明变量,所有这些都没有成功。
我要实现的目标是PLATFORM_HOME可以从其他以该基准为基础的Dockerfile引用。怎么做 ?
我正在尝试使用 docker-compose up 构建一个 docker 文件,但出现错误:
/bin/sh: 1: poetry: not found
ERROR: Service 'web' failed to build: The command '/bin/sh -c poetry install && bundler install' returned a non-zero code: 127
Run Code Online (Sandbox Code Playgroud)
这是我的 docker 文件和 docker-compose-yml 文件: dockerfile:
FROM python:2.7
ENV LIBRARY_PATH=/lib:/usr/lib
RUN curl -sSL https://raw.githubusercontent.com/sdispater/poetry/master/get-poetry.py | python
WORKDIR /stream
ADD . /stream
CMD ["cat", "/etc/os-release"]
RUN poetry install && \
bundler install
EXPOSE 8000
CMD ["poetry", "run", "python", "manage.py", "runserver", "0.0.0.0:8000"]
Run Code Online (Sandbox Code Playgroud)
docker-撰写:
version: '3'
services:
redis:
image: redis
ports:
- …Run Code Online (Sandbox Code Playgroud)