V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
twotiger
V2EX  ›  Docker

学了一段时间,分享个部署 jupyter notebook

  •  
  •   twotiger · 2018-02-03 16:02:54 +08:00 · 3336 次点击
    这是一个创建于 2268 天前的主题,其中的信息可能已经有所发展或是发生改变。

    支持 python2, python3.5,可远程访问

    创建 doc 文件夹,将 doc 挂载到容器中, 默认密码hello

    mkdir doc
    
    FROM ubuntu:latest
    
    # 为 notebook 建立的镜像
    RUN apt-get update
    RUN apt-get install -y openssh-server vim python python3.5 net-tools python-pip python3-pip
    # 必须要升级 pip
    RUN pip3 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -U pip
    RUN pip2 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com -U pip
    RUN pip2 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com  ipython==5.5.0 notebook==5.4.0
    RUN pip3 install -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com notebook==5.4.0
    
    
    #RUN sed -ri 's/PermitRootLogin.*?/PermitRootLogin yes/g' /etc/ssh/sshd_config
    #RUN echo "root:123456" | chpasswd
    
    RUN jupyter notebook --generate-config
    RUN mkdir -p /opt/jupyter
    RUN sed -i '$a\c.NotebookApp.password = u"sha1:44d5994cc0cd:d6d4104f78a887d14de9624daa05836aa34cc443"\nc.NotebookApp.ip="*"\nc.NotebookApp.allow_root = True\nc.NotebookApp.notebook_dir = u"/opt/jupyter"' /root/.jupyter/jupyter_notebook_config.py
    
    EXPOSE 8888
    CMD ["jupyter-notebook"]
    

    创建镜像

    创建容器

    docker build -t notebook:latest .
    docker run  -p 8888:8888 -v $PWD/doc:/opt/jupyter -itd notebook:latest
    
    6 条回复    2018-02-04 15:04:48 +08:00
    defunct9
        1
    defunct9  
       2018-02-03 18:35:35 +08:00 via iPhone
    jupyter 是做什么用的呢
    takato
        2
    takato  
       2018-02-03 19:14:13 +08:00 via iPhone
    和官方的 image 有什么不同吗?
    julyclyde
        3
    julyclyde  
       2018-02-04 08:17:19 +08:00
    为什么屁大点事都要弄个 docker ?
    twotiger
        4
    twotiger  
    OP
       2018-02-04 09:06:25 +08:00
    @julyclyde 那你用 docker 做了什么比屁大点事大的事呢,分享下吧
    twotiger
        5
    twotiger  
    OP
       2018-02-04 09:32:48 +08:00
    @takato 用国内的源,算么-_-!
    julyclyde
        6
    julyclyde  
       2018-02-04 15:04:48 +08:00
    @twotiger 我把我们公司客服人员“猫儿盖屎”式的 docker 都解开,用正经打包格式和标准路径的重新部署了应用
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2779 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 09:49 · PVG 17:49 · LAX 02:49 · JFK 05:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.