docker中安装jupyter,远程访问

进入docker交互式环境:docker exec -it ***** bash

安装jupyter:

  • 安装python dev包 :  apt-get install python-dev
  • 安装jupyter :  pip install jupyter [若pip没安装好,需要安装sudo apt install python3-pip]

配置文件:

  • 生成jupyter配置文件:jupyter notebook --generate-config
  • 使用ipython生成密码 

In [1]: from notebook.auth import passwd

In [2]: passwd()

Enter password:

Verify password:

Out[2]: 'sha1:******'

  • 到配置文件/root/.jupyter/jupyter_notebook_config.py中修改以下参数

c.NotebookApp.ip='*'                          #绑定所有地址,即所有IP 地址都可以访问
c.NotebookApp.password = u'sha1:******'
c.NotebookApp.open_browser = False            #启动后是否在浏览器中自动打开
c.NotebookApp.port =8100                      #指定一个访问端口8100,默认8888

c.NotebookApp.allow_remote = True     #将远程访问设置成True

启动:

jupyter notebook --allow-root

远程访问:

  • 查看docker IP,需安装  apt install net-tools ,然后输入命令ifconfig -a。

找到inet后的IP地址即为docker地址。如:inet  153.16.0.1

  • 远程访问:http://153.16.0.1:8100即可。8100为配置文件时修改的启动端口,若有密码,即token=  后面输入密码。/

猜你喜欢

转载自www.cnblogs.com/Lee-yl/p/12163947.html