Python - Ananconda in Docker Container¶
How to run a full fledged Anaconda jupyter notebook that has all the components pre-installed
- Simplified Docker-ing for Data Science — Part 1 – Becoming Human: Artificial Intelligence Magazine
- Getting started with Anaconda & Docker – Patrick Michelberger – Medium
1. Pull the docker container¶
$ ~ >> docker pull continuumio/anaconda3 #got the following output: Using default tag: latest latest: Pulling from continuumio/anaconda3 05d1a5232b46: Pull complete 33529d049adc: Pull complete be72550a31b7: Pull complete 40cab810eef6: Pull complete Digest: sha256:a1da4c02879f7e1e16733fda772b074bbf4890cf1146fbf999d61d031b150f68 Status: Downloaded newer image for continuumio/anaconda3:latest
2. To log in to the docker container, we can run the command below:¶
docker run -i -t continuumio/anaconda3 /bin/bash
3. To run Jupyter notebook in a no-browser mode, run the command below:¶
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='0.0.0.0' --port=8888 --no-browser --allow-root”
Note on what the command is doing:
-i is running the image interactively.
-t is allocate a pseudo-TTY.
-p is connect/publish the container ports to host.
Here localhost:8888 to 8888 of container.
A few more that you should know are:
-d is to run container in the background, without accidently closing it.
-v is to bind a volume to the container, useful when you want your notebooks and/or data to be reflected in the container from your local system.
4. Go to the browser and run http://localhost:8888 to start running your experiments.¶
- A token is generated. Copy that from the command line and paste in the browser to use the jupyter notebook.
- The command from the two Medium.com posts does not work coz of the part
Changing that to
ip=0.0.0.0does the trick.
Info from: anaconda - running conda's jupyter on docker - Stack Overflow.