美文网首页
Jupyter 安装配置 及 docker镜像制作

Jupyter 安装配置 及 docker镜像制作

作者: 金刚_30bf | 来源:发表于2018-07-03 14:36 被阅读0次

安装annconda 后在bin目录下有 jupyter notebook 。

配置文件

使用jupyter notebook --generate-config 生成配置文件,
文件地址在 :~/.jupyter/jupyter_notebook_config.py

  1. 修改登录密码 :

加密密码通过如下方法得到:
执行ipython :

In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password: 
Verify password: 
Out[2]: 'sha1:ca79443814aa:39da96bddeaf27b8846e59747c6a0726dad42fae'

将上述输出拷贝到配置文件 jupyter_notebook_config.py 中
c.NotebookApp.password = 'sha1:ca79443814aa:39da96bddeaf27b8846e59747c6a0726dad42fae'

  1. 修改notebook的初始化目录 , 在jupyter_notebook_config.py 中
"notebook_dir":"/dubook"

后续保存的.ipynb文件都会在该目录 。

启动命令:

jupyter notebook --ip="*" --allow-root --no-browser

--no-browser : 本地不启动浏览器
--allow-root: 允许所有用户
--ip="*" : 允许所有ip连接
--port 9999 : 指定端口 ,默认 8888

docker 镜像制作

基于 centos7 .

  1. docker 启动centos镜像 , docker run -v /root/data:/data -ti centos /bin/bash
  2. 在镜像中安装 annconda , 配置 jupyter notebook 。
  3. 制作 notebook启动脚本。
  4. 退出docker 镜像
  5. 使用docker commit ,将退出的容器保存为新的镜像
  6. 制作dockefile
  7. 使用docker build 根据dockerfile制作自启动镜像
  8. 将镜像push到私有仓库
  9. 制作kubectl deployment 文件, 创建Deployment
    10.执行 kubectl service 对外提供服务nodeport
  10. 在外访问之。

启动脚本:

echo "start jupyter notebook "
# jupyter notebook > jupyter.log
source /etc/profile

python --version

jupyter notebook --ip="*" --allow-root  --no-browser > jupyter.log &

将 anaconda3/bin 加入到/etc/profile 下。

docker file

FROM centos-tensorflow:v1
MAINTAINER xxx
WORKDIR /usr/Anaconda3

EXPOSE 8888

ENTRYPOINT ./starjupynb.sh && tail -F ./jupyter.log

相关文章

网友评论

      本文标题:Jupyter 安装配置 及 docker镜像制作

      本文链接:https://www.haomeiwen.com/subject/gclduftx.html