Docker Community Forums

Share and learn in the Docker community.

How to re run the continumio/anaconda3 docker container?

dockerhub

#1

I followed instructions on https://hub.docker.com/r/continuumio/anaconda3 and was able to get jupyter notebook running (also added the --allow-root to the command)

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

But when trying to re-run the same container with command

docker start <CONTAINER_ID> && docker exec -d -t <CONTAINER_ID> /bin/bash -c "/opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

The container works for a while and then dies. Even if I only start notebook container, it automatically dies after sometime.

Has anyone else encountered the same problem with continumio anaconda image ? How do I resolve it ?


#2

Sharing the stackoverflow answer :

If you inspect the log on stopped container it shows mkdir: cannot create directory ‘/opt/notebooks/’: File exists. The issue is with docker start it reruns the provided command: /bin/bash -c “… && mkdir /opt/notebooks && …”, so it would fail at second attempt

I need to run the same command with -p flag

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c  "/opt/conda/bin/conda install jupyter -y --quiet && mkdir -p /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser --allow-root"

And to restart a stop container

docker start <CONTAINER_ID>