一.拉取镜像
拉取一个自带miniconda的镜像源:
docker pull continuumio/miniconda3
二.启动容器
docker run -id -p 宿主机端口:容器端口 --name 自己取的容器名 -v 宿主机目录:容器目录 --user root
continuumio/miniconda3:latest
三.容器内安装jupyter notebook
apt-get update
apt-get install python-dev
pip install jupyter
四.配置jupyter
#初始化jupyter_notebook_config.py
jupyter notebook --generate-config
vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.password=''
c.NotebookApp.ip='*'
c.NotebookApp.allow_remote_access = True
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
c.NotebookApp.port = xxxx #xxxx为容器端口
#启动jupyter
jupyter notebook
如果想设置密码的话,
#初始化jupyter_notebook_config.py
jupyter notebook --generate-config
ipython #进入ipython
[1]:from notebook.auth import passwd
[2]:passwd()
然后输入密码
out[2]:'生成一串密钥'
#复制密钥并保存
vim /root/.jupyter/jupyter_notebook_config.py
c.NotebookApp.password='密钥'
c.NotebookApp.ip='*'
c.NotebookApp.allow_remote_ccess = True
c.NotebookApp.open_browser = False
c.NotebookApp.port = xxxx #xxxx为容器端口
#启动jupyter
jupyter notebook
五.防火墙设置
将对应的宿主机端口打开即可
六.启动jupyter,并远程连接
#启动jupyter,在容器中
jupyter notebook --allow-root
在浏览器中输入宿主机ip:宿主机端口,,,,,,完成