(1)利用镜像ubuntu形成容器notebook_0【路径必须加】
docker run -itd --name notebook_0 -d -v /home/qiao/docker_qiao/jupyter:/home/qiao/jupyter ubuntu:18.04
(2)进入容器notebook_0:
docker exec -it notebook_0 /bin/bash
(3) 更新apt并装pip
apt update
apt install python3-pip vim locales fonts-wqy*
(4)装jupyter和常用包
pip3 install --upgrade --force-reinstall --no-cache-dir jupyter
(5)修改jupyter配置文件
5.1 jupyter notebook --generate-config
5.2 vim ~/.jupyter/jupyter_notebook_config.py
#c.NotebookApp.allow_root = True
c.NotebookApp.open_browser = False
c.NotebookApp.ip = ‘*‘
c.NotebookApp.port = 8221
c.NotebookApp.notebook_dir = ‘/home/qiao/jupyter‘
5.3 然后保存退出
5.4 检测是否安装成功:jupyter notebook --allow-root
(6)把容器notebook_0提交到镜像notebook_image
docker commit notebook_0 notebook_image
(7)开另一个终端,删除容器notebook_0
docker stop notebook_0
docker rm notebook_0
(8)#利用镜像notebook_image生成容器notebook_container
docker run -itd --name notebook_container -p 8222:8221 -v /home/qiao/docker_qiao/jupyter:/home/qiao/jupyter notebook_image
容器内运行:
docker exec -it notebook_container /bin/bash
jupyter notebook --allow-root
容器外运行:docker exec notebook_container jupyter notebook --allow-root &
原文:https://www.cnblogs.com/hapyygril/p/11434546.html