V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
twotiger
V2EX  ›  Docker

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

  •  
  •   twotiger · Feb 3, 2018 · 4114 views
    This topic created in 3010 days ago, the information mentioned may be changed or developed.

    支持 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 replies    2018-02-04 15:04:48 +08:00
    defunct9
        1
    defunct9  
       Feb 3, 2018 via iPhone
    jupyter 是做什么用的呢
    takato
        2
    takato  
       Feb 3, 2018 via iPhone
    和官方的 image 有什么不同吗?
    julyclyde
        3
    julyclyde  
       Feb 4, 2018
    为什么屁大点事都要弄个 docker ?
    twotiger
        4
    twotiger  
    OP
       Feb 4, 2018
    @julyclyde 那你用 docker 做了什么比屁大点事大的事呢,分享下吧
    twotiger
        5
    twotiger  
    OP
       Feb 4, 2018
    @takato 用国内的源,算么-_-!
    julyclyde
        6
    julyclyde  
       Feb 4, 2018
    @twotiger 我把我们公司客服人员“猫儿盖屎”式的 docker 都解开,用正经打包格式和标准路径的重新部署了应用
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2468 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 45ms · UTC 11:53 · PVG 19:53 · LAX 04:53 · JFK 07:53
    ♥ Do have faith in what you're doing.