docker容器中jupyter自动补全配置和ssh配置

jupyter安装自动补全插件:

pip install jupyter_contrib_nbextensions

jupyter contrib nbextension install --user

pip install --user jupyter_nbextensions_configurator

jupyter nbextensions_configurator enable --user

在浏览器中进入打开的jupyter,选择Files  running clusters nbextensions中的nbextensions。选择Hinterland,打开即可。

 

jupyter修改登录密码:

输入jupyter notebook --generate-config生成配置文件,位置为"/当前用户名/.jupyter/jupyter_notebook_config.py"。如root用户为:"/root/.jupyter/jupyter_notebook_config.py"

产生密码:

命令行输入:

python,进入python的编辑状态;接下来输入:

from notebook.auth import passwd

passwd()

输入密码,记录下生成的哈希密码sha1

打开配置文件,即上面产生的.py文件,设置c.NotebookApp.password=哈希值(注意要加sha1:);

设置默认打开的端口:c.NotebookApp.port = 8888

 

docker安装ssh:

首先更新apt-get update

输入命令apt-get install openssh-server

修改设置:vim /etc/ssh/sshd_config

PermitRootLogin改为yes

端口改为需要的端口

ssh打开或关闭的命令为:/etc/init.d/ssh start (or stop)

连接时输入的密码为用户的密码;例如用户为root,则输入root的密码(修改用户密码 passwd)

 

可以创建一个sh文件直接打开jupyter和ssh:

创建名为run.sh的文件,使用chmod命令加入可执行权限。

一些docker容器已经有了run_jupyter.sh文件,可以修改后运行,也可以直接将其替换为对应的命令。

输入vi run.sh,进行编辑;

输入以下内容:

#!/usr/bin/env bash

echo 'Begining to run run_jupyter.sh'

sh /run_jupyter.sh # 或者替换为nohup jupyter notebook "$@" --allow-root --ip=0.0.0.0 --port=8000 > jupyter.out 2>&1 &等等

echo 'Running run_jupyter finished'

nohup /etc/init.d/ssh start > ssh.out 2>&1 &

echo 'Running run.sh finished'

运行run.sh文件,即可打开ssh和jupyter。

上述命令使用的是后台运行,需要关闭jupyter时,可以查找进程id,然后杀掉。

输入ps -aux | grep jupyter

输入kill -9 5265杀掉jupyter进行。

ssh可使用ssh的打开和关闭命令。

 

 

# 参考了一些文章,但具体那些已经忘记了

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值