我正在尝试在 Dockerfile ( FROM nvidia/cuda:8.0-cudnn5-devel-ubuntu16.04
)中安装和设置 pyenv
这是 Dockerfile 的后半部分(前半部分只是安装依赖项):
RUN useradd -ms /bin/bash user && echo "user:resu" | chpasswd && adduser user sudo
USER user
WORKDIR /home/user
# install pyenv
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
ENV HOME /home/user
ENV PYENV_ROOT $HOME/.pyenv
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> .bashrc
RUN echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> .bashrc
RUN echo 'eval "$(pyenv init -)"' >> .bashrc
RUN pyenv install 2.7.10
# install pyenv-virtualenv
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git .pyenv/plugins/pyenv-virtualenv
RUN echo 'eval "$(pyenv virtualenv-init -)"' >> .bashrc
# setup virtualenv
RUN pyenv virtualenv 2.7.10 foo
RUN /bin/bash -c ' source .bashrc && \
pyenv activate foo && \
pip install numpy && \
pip install nltk'
Docker 安装在最后一行失败:
Step 20 : RUN /bin/bash -c ' source .bashrc && pyenv activate foo && pip install numpy && pip install nltk'
---> Running in 672826e55a40
Failed to activate virtualenv.
Perhaps pyenv-virtualenv has not been loaded into your shell properly.
Please restart current shell and try again.
这里有什么问题 ?是否有使用 Docker 设置 pyenvs 的最佳实践?