如何在Glue Jupyter容器中切换至Jupyter Notebook而非Labs?
切换AWS Glue容器中的Jupyter Lab到Notebook的方法
方法1:直接访问Notebook路径(无需修改容器)
直接在浏览器访问 127.0.0.1:8888/tree,即可进入传统的Jupyter Notebook界面,无需调整容器内的服务。
方法2:进入容器切换启动Notebook
如果需要默认启动Notebook而非Lab,可按以下步骤操作:
- 进入容器的bash环境:
docker exec -it glue_jupyter bash - 停止当前运行的Jupyter服务:
先查看Jupyter进程ID:
用kill命令终止对应进程(替换ps aux | grep jupyter<pid>为查到的进程号):
或者直接执行:kill <pid>jupyter server stop - 启动Jupyter Notebook服务(需绑定0.0.0.0确保外部可访问):
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser - 回到宿主机浏览器,访问
127.0.0.1:8888即可进入Notebook界面。
方法3:重新启动容器时指定Notebook启动命令
如果还没启动容器,或者可以重新创建容器,直接替换启动命令为Notebook的启动指令:
docker run -itd -p 8888:8888 -p 4040:4040 --name glue_jupyter amazon/aws-glue-libs:glue_libs_2.0.0_image_01 jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser
方法4:修改Jupyter配置默认打开Notebook
进入容器后,修改Jupyter配置文件,让服务默认加载Notebook界面:
- 进入容器bash:
docker exec -it glue_jupyter bash - 生成或编辑Jupyter配置文件:
如果没有配置文件,先生成:
编辑配置文件(路径通常为jupyter notebook --generate-config/home/glue_user/.jupyter/jupyter_notebook_config.py):vi /home/glue_user/.jupyter/jupyter_notebook_config.py - 找到并修改以下配置项(如果没有就添加):
# 旧版本Jupyter用这个 c.NotebookApp.default_url = '/tree' # 新版本Jupyter可能用ServerApp c.ServerApp.default_url = '/tree' - 重启Jupyter服务后,访问
127.0.0.1:8888就会默认进入Notebook界面。
内容的提问来源于stack exchange,提问作者Shivam Anand
相关产品推荐
相关产品推荐

