Jupyter password and Docker

随声附和 提交于 2019-12-11 03:06:42

问题


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.


回答1:


Create a hashed password, using the ipython terminal

from notebook.auth import passwd
passwd()

It will promote you to enter the passwd twice, and create the hashed password, and add following lines in the Docker file

RUN jupyter notebook --generate-config
RUN echo "c.NotebookApp.password='sha1:***'">>/root/.jupyter/jupyter_notebook_config.py

Since I am the only person using the notebook, I just sticked to the root.



来源:https://stackoverflow.com/questions/48875436/jupyter-password-and-docker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!