Issue
For changing / setting the password of a Jupyter server, I follow the instructions here:
http://jupyter-notebook.readthedocs.io/en/latest/public_server.html#preparing-a-hashed-password
I do this in my local ipython environment. One thing to note is that somehow I get different hashes every time I re-run the passwd()
command for the same password, but I assume that's intended behavior.
Anyway. I get the hash, and then I have a line like this in a Dockerfile:
ENV PW_HASH="u'sha1:salt:hash'"
and in the start-up script for the jupyter notebook I have
echo "c.NotebookApp.password = ${PW_HASH}" >> ${CONFIG_PATH}
and then
jupyter notebook --allow-root -y --no-browser --ip=0.0.0.0 --config=${CONFIG_PATH}
However, if I then run the docker container via
docker run -it -p 8888:8888 <container-name>
while it does start up jupyter and allows me to connect in my browser via localhost:8888
, it won't accept the password I just set via its hash.
Strangely, it does work when I add the additional step of the SSL certificates (and go to https://localhost:8888). What's going on here?
PS: I know that having a password but no SSL is sketchy. I'm just testing it out step by step and wonder why it won't work without the SSL part.
Solution
Found two possible solutions, I tested both and both works.
jupyter core : 4.6.3
jupyter-notebook : 6.0.3
Set password
"add option -e PASSWORD=password
to set the environment variable. The set password is then the password for the jupyter login." [1] when docker run
or
environment:
- PASSWORD=password
when using Docker Compose. Then just enter password
Set token
"… There already exists an easy way of setting the token when starting one of the Jupyter notebook Docker containers: -e JUPYTER_TOKEN="easy; it's already there"
. In fact, things are even easier if you export JUPYTER_TOKEN='easy'
in the local environment, and then start the container with docker run --rm -d --name democontainer -p 9999:8888 -e JUPYTER_TOKEN jupyter/base-notebook
(which is equivalent to -e JUPYTER_TOKEN=$JUPYTER_TOKEN
). You can then autolaunch into the notebook with open http://localhost:9999?token=${JUPYTER_TOKEN}
. H/t @minrk for that…" [2]
when using Docker Compose
environment:
- JUPYTER_TOKEN=easy
then run just http://localhost:9999?token=easy
or automate more ...
[1] login password required to access jupyter notebook running in nvidia-docker container
Answered By - mimros
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.