Docker搭建jupyterlab
2022/2/27 23:25:31
本文主要是介绍Docker搭建jupyterlab,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
拉镜像
docker pull captainji/jupyterlab
启动jupyterlab服务
docker run -d \ -p 8888:8888 \ -e JUPYTER_ENABLE_LAB=yes \ -v /data/docker/jupyter:/usr/local/src/jupyterlab_workspace \ -v /usr/share/zoneinfo/Asia/Shanghai:/etc/localtime \ -v /etc/timezone:/etc/timezone \ --restart=always \ --name JupyterLab captainji/jupyterlab
获取jupyterlab 访问的token
# 获取容器日志,看日志中的token docker logs JupyterLab #################################### [I 2022-02-27 21:41:33.955 ServerApp] http://3c12d28a99a2:8888/lab?token=97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c [I 2022-02-27 21:41:33.955 ServerApp] or http://127.0.0.1:8888/lab?token=97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c [I 2022-02-27 21:41:33.955 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation). [C 2022-02-27 21:41:33.958 ServerApp] To access the server, open this file in a browser: file:///root/.local/share/jupyter/runtime/jpserver-7-open.html Or copy and paste one of these URLs: http://3c12d28a99a2:8888/lab?token=97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c or http://127.0.0.1:8888/lab?token=97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c #################################### 上面链接中的97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c 就是访问的token
访问jupyterlab
# 注意:云服务器的话必须开通端口8888的防火墙,否则访问不到 http://服务器ip:8888/lab?token=97c99de9e4b3ea86ebf567d8e1290c11023d165b7351156c
设置jupyterlab自定义密码访问
查看jupyterlab 配置
# 进入容器 docker exec -it JupyterLab /bin/bash # 进入jupyterlab配置文件所在目录 cd ~/.jupyter/ # 利用ipython生成密码 root@3c12d28a99a2:~/.jupyter# ipython Python 3.8.6 (default, Sep 25 2020, 09:36:53) Type 'copyright', 'credits' or 'license' for more information IPython 7.19.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: from notebook.auth import passwd In [2]: passwd() Enter password: Verify password: Out[2]: 'argon2:$argon2id$v=19$m=10240,t=10,p=8$R7ikdjMB7JBPTsV/XZPwUA$WYIpSx6zvn9H2HI4XIEHyA'
修改jupyterlab 配置文件
vi jupyter_lab_config.py # 在配置文件底部增加以下内容(shift+g直接到文件底部) c.NotebookApp.password ='argon2:$argon2id$v=19$m=10240,t=10,p=8$R7ikdjMB7JBPTsV/XZPwUA$WYIpSx6zvn9H2HI4XIEHyA' #秘钥(上一步获取的密钥)
重启jupyterlab容器
docker restart JupyterLab # 关闭浏览器重新访问
这篇关于Docker搭建jupyterlab的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-11-14Docker端口:你真的公开了哪些东西?
- 2024-11-14用DOCKER在家里的实验室里搞些酷炫的玩意儿
- 2024-11-05掌握Docker:高效安全的十大最佳实践
- 2024-11-05在 Docker Compose 中怎么设置端口映射-icode9专业技术文章分享
- 2024-11-05在 Docker Compose 中怎么设置环境变量-icode9专业技术文章分享
- 2024-11-04Docker环境部署项目实战:新手入门教程
- 2024-11-04Docker环境部署资料:新手入门教程
- 2024-11-01Docker环境部署教程:新手入门指南
- 2024-11-01超越Docker:苹果芯片上的模拟、编排和虚拟化方案讲解
- 2024-11-01Docker环境部署:新手入门教程