docker容器下配置jupyter notebook遠端訪問
阿新 • • 發佈:2022-04-11
安裝jupyter
apt update
pip install jupyter
jupyter預設只能通過本地訪問,要開放配置,允許遠端訪問。在開放遠端訪問時,jupyter的配置檔案只支援加密後的密文密碼
#生成jupyter配置檔案,這個會生成配置檔案.jupyter/jupyter_notebook_config.py jupyter notebook --generate-config #使用ipython生成密碼 In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'sha1:******' #去配置檔案/root/.jupyter/jupyter_notebook_config.py中修改以下引數 c.NotebookApp.ip='*' #繫結所有地址 c.NotebookApp.password = u'剛才生成的密碼' c.NotebookApp.open_browser = False #啟動後是否在瀏覽器中自動開啟 c.NotebookApp.port =8888 #指定一個訪問埠,預設8888,注意和對映的docker埠對應 c.NotebookApp.allow_remote_access = True #允許遠端訪問
配置完成以後,就可以用 jupyter notebook命令把jupyter啟動起來了,如果在容器中直接使用的root使用者,啟動jupyter的命令為jupyter notebook --allow-root