Halo
发布于 2023-02-17 / 113 阅读 / 0 评论 / 0 点赞

docker jupyter notebook

创建jupyter notebook 存放目录

mkdir /home/jack/jupyter_notebook

运行docker

sudo docker run -id -p 8100:8888 -m 2g --name jupyter_notebook_jack --restart always -v /home/jack/jupyter_notebook:/root --user root ubuntu:latest

进入容器

sudo docker exec -it jupyter_notebook_jack /bin/bash
cd ~

安装 notebook

apt update
apt upgrade -y
apt install -y nano python3 python3-pip
pip3 install notebook

配置jupyter notebook

mkdir /root/.jupyter
nano /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '0.0.0.0' # listen on all IPs 运行所有设备登录
c.NotebookApp.token = ''     # disable authentication 免密码登录
c.NotebookApp.allow_origin = '*' # allow access from anywhere
c.NotebookApp.disable_check_xsrf = True # allow cross-site requests
c.NotebookApp.port = 8888
c.NotebookApp.tornado_settings = { 'headers': { 'Content-Security-Policy': "frame-ancestors * 'self' " }}
c.NotebookApp.notebook_dir = '/root'

后台运行jupyter notebook

nohup jupyter notebook --allow-root &
nano /etc/rc0.d/start_jupyter_notebook.sh
#!/bin/sh
jupyter notebook --allow-root  >> /root/nohup.out &

验证

浏览器打开: http://127.0.0.1:8100/tree?


评论