【发布时间】:2019-08-03 01:15:57
【问题描述】:
我需要在 docker 中激活环境并在此环境中运行命令。 我创建了环境,然后我尝试激活这个环境并以这种方式运行命令:
CMD [ "source activate mro_env && ipython kernel install --user --name=mro_env" ]
但是当我运行 docker 时出现错误:
[FATAL tini (8)] exec source activate mro_env && ipython kernel install
--user --name=mro_env failed: No such file or directory
这是整个 Dockerfile:
FROM continuumio/miniconda3
ADD /src/mro_env.yml /src/mro_env.yml
RUN conda env create -f /src/mro_env.yml
# Pull the environment name out of the mro_env.yml
RUN echo "source activate $(head -1 /src/mro_env.yml | cut -d' ' -f2)" > ~/.bashrc
ENV PATH /opt/conda/envs/$(head -1 /src/mro_env.yml | cut -d' ' -f2)/bin:$PATH
CMD [ "source activate mro_env && ipython kernel install --user --name=mro_env" ]
【问题讨论】:
-
请向我们展示您的 Dockerfile;看起来您实际上并没有最终创建
mro_env环境。也请查看official documentation 以获取 CMD 指令。 -
@JordanSinger 我添加了 Dockerfile
-
你确定你的环境创建成功了吗?
-
@FabienP 是的。环境安装成功。问题是与 jupyter notebook 的集成。我的目标是在 jupyter 上安装环境,并用这个环境启动 jupyter。你知道我该怎么做吗?
-
我这样做的方式通常是在环境中安装 Jupyter,然后从那里启动它。否则,您可以查看
nb_conda_kernels以从您的 Jupyter 服务器访问此环境。
标签: python docker anaconda conda