1. 安装Anaconda3
# docker pull continuumio/anaconda3:latest
2. 启动Anaconda3并转发端口8888到527(安全第一位~)
# 5fbf7bac70a0 是我的Anaconda3 IMAGE ID
# docker run -it -d -p 0527:8888 5fbf7bac70a0
3. 使用exec
进入Anaconda3,开启Jupyter
# a45e08558a34 是我的CONTAINER ID
# docker exec -it a45e08558a34 /bin/bash
3.1 使用ipython生成密码
# ipython //进入ipython交互模式
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:18d8142a9322:a8b0ab5078fa801c524a459594c40511abc48970'
3.2 生成jupyter配置文件
# jupyter notebook --generate-config
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
3.3 修改默认配置文件
# vi ~/.jupyter/jupyter_notebook_config.py
直接在最上面插入
c.NotebookApp.ip='*' # 设置所有ip皆可访问
c.NotebookApp.password = u'sha1:上面生成的哈希值' #
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port = 8888 #指定一个端口
c.notebookapp.notebook_dir = "/usr/local/src" # 设置默认存储路径
4 启动jupyter
# jupyter notebook --allow-root