Docker Community Forums

Share and learn in the Docker community.

How to get token and password to work for jupyter/datascience-notebook

Hi

I am new to Docker and pulled a jupyter/datascience-notebook using

docker pull jupyter/datascience-notebook

I then ran:

docker run eaac14a737db to start the container

One of the last lines gave me a url:
http://127.0.0.1:8888/?token=fc99f4e80383e7ba3c50a805ebe312766c1e66a3e15da8cc

I pasted that in, and came to the login page of the Jupyter Notebook, where Token authentication is required.

I copied the token from the last line (fc99f4e80383e7ba3c50a805ebe312766c1e66a3e15da8cc) into the box, but to no avail.

Am I missing something obvious?

I ran jupyter notebook list command to see active sessions, and pasted the key in, but then was redirected to my regular jupyter notebook homepage, which is running python from my local machine, and not in the docker container.

Hi, Thanks for your question! Did you possible find an answer to this? I am dealing with the same issue.

Hi

I found a solution, and this is the way I did it:
1 - run docker ps -a to see containers presently loaded
2 - run docker system prune to remove all stopped containers
3 - run docker stop ea34 to stop any continer running, and remove it wtih docker system prune
4 - search images with docker images
5 - run docker run -p 8888:8888 --name jupyter folium2
6 - got this:


7 - copied http link from bottom, and it worked from then on

Hope this helps anyone else!

Thanks, but this did not work for me. I really don’t know what else it could be. ugh. Thanks again!

I use anaconda3 for my Jupyter notebooks and this is the command I use to start them without any problems:

docker run --rm -p 8888:8888 -v $(PWD):/opt/notebooks continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/jupyter notebook --ip=0.0.0.0 --port=8888 --notebook-dir=/opt/notebooks --allow-root --no-browser"

Of course I don’t type that in every time. I created an alias that I stored in my ~/.bash_profile file (I’m on a Mac). This is the line I put in my ~/.bash_profile:

alias jupyter='docker run --rm -p 8888:8888 -v $(PWD):/opt/notebooks continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/jupyter notebook --ip=0.0.0.0 --port=8888 --notebook-dir=/opt/notebooks --allow-root --no-browser"'

The key things here are -v $(PWD):/opt/notebooks which shares your current working directory in the Docker container. This way your files are saved on your computer and not inside the container. The other key parameters are --allow-root --no-browser because docker containers run as root by default and the container cannot see the browser on your computer so you must tell Jupyter not to look for one.

Then whenever I want to use a Jupyter notebook, I change into the directory where I want/have my notebook .ipynb files and I just type:

$ jupyter

and I paste the URL in my browser and it all works.

Hope this helps.

~jr