Docker Community Forums

Share and learn in the Docker community.

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


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:

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.


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!

1 Like

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= --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= --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.



Hi, I used to have the same problem.

The solution was a little tricky

First I ran a new datascience-notebook container using the command:

docker run -it -v $PWD:/root/compartido -p 8888:8888 --name “data_science” jupyter/datascience-notebook:latest

it gave me a url like the one you got, then I stop the jupyter server with the quit bottom, after that I start again my conteiner using it’s name:

docker start data_science

I went to the server page

and the token authentication page show up.

soooo I didn’t close the page, I stop the server with the command

docker stop data_science

then I removed the conteiner with

docker rm data_science

I create a new container with the first command I wrote here, and use the new token it gave to set a password in the token authentication page (there is an option at the end of the page).

After that, every time I stop and start my container, the jupyter page ( just ask for the password.

hope this helps you.

Running Jupyter Notebook on a remote server
Launch Jupyter Notebook from remote server using port 8080: jupyter notebook --no-browser --port=8080. Or run the following command to launch with default port: jupyter notebook --no-browser. …
You can access the notebook from your remote machine over SSH by setting up a SSH tunnel.

I’m trying to run Jupyter using your commands. It partially works, if I run this command sudo docker run --user root -p 8888:8888 -v $PWD:/home/jovyan -e CHOWN_HOME=yes -e CHOWN_HOME_OPTS='-R' --name notebook jupyter/tensorflow-notebook

I get the following error chown: cannot access '/home/jovyan/.gvfs': Permission denied

I’m running Docker on remote server, but I don’t know it much.

Thank you

Command in background, the token to open Jupyterlab doesnt work
docker run -d -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes jupyter/minimal-notebook:latest
Command run in foreground, the token to open Jupyterlab works
docker run -p 8888:8888 -e JUPYTER_ENABLE_LAB=yes jupyter/minimal-notebook:latest
I am running docker on ec2 instance and I ssh to access the notebooks in local.