Docker Community Forums

Share and learn in the Docker community.

Installed environment on jupyter

I want to build a container that his purpose is to install environment on jupyter, and then launch the jupyter with the environment I just installed.
I tried using this dockerfile:

FROM continuumio/miniconda3
ADD /src/mro_env.yml /src/mro_env.yml
RUN conda env create -f /src/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
COPY src/Project.ipynb work/
RUN echo "ipython kernel install --user --name=mro_env"
CMD [ "sh", "-c", "jupyter notebook" ]

The project I to want to launch is “Project.ipynb” and the environment is “mro_env.yml”.
It seems that the installation of the environment is done successfully, and also the installation of the environment as kernel in jupyter. the problem is that the CMD command is not doing anything, so when I run the container it just launch the environment and that’s all.
I also tried to launch the jupyter using the command:

docker run -p 8888:8888 jupyter-container

while the name of the container I created in the building step is “jupyter-container”, but it couldn’t launch jupyter and was an error.