我是靠谱客的博主 犹豫草莓,这篇文章主要介绍外部环境构建jupyterlab-notebook镜像,现在分享给大家,希望可以做个参考。

示例Dockerfile

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
FROM # path conda ENV PATH="/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda /bin:${PATH}" NVIDIA_VISIBLE_DEVICES=all CONDA_DIR=/opt/conda MINICONDA_VERSION=4.7.5 SHELL=/bin/bash LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 HOME=/root # tini RUN env |grep -iE "cuda|nvidia|cudnn" | sed 's/^/export &/g' > /etc /profile.d/cuda-env.sh && sed -i "s#$CONDA_DIR/bin:##g" /etc/profile.d/cuda-env.sh && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen && wget --quiet https://github.com/krallin/tini/releases/download/v0.10.0 /tini && echo "1361527f39190a7338a0b434bd8c88ff7233ce7b9a4876f3315c22fce7eca1b0 *tini" | sha256sum -c - && mv tini /usr/local/bin/tini && chmod +x /usr/local/bin/tini RUN echo "set directory=/root/.vim/swapfiles/" > /root/.vimrc && echo "set backupdir=/root/.vim/backups/" >> /root/.vimrc && mkdir -p /root/.vim/swapfiles && mkdir -p /root/.vim/backups # jupyterlab ADD . /src/jupyter RUN npm config set registry http://registry.npm.taobao.org/ && cd /src/jupyter/jupyterhub && npm install --unsafe-perm && pip install . && cp -R /src/jupyter/notebook /src/jupyter/jupyterhub && cp /src/jupyter/notebook/start.sh /usr/local/bin/ && cp /src/jupyter/notebook/start-notebook.sh /usr/local/bin/ && cp /src/jupyter/notebook/start-singleuser.sh /usr/local/bin/ && cp /src/jupyter/notebook/jupyter_notebook_config.py /usr/local/bin/ && cp /src/jupyter/bmlmodel/bmlmodel /usr/local/bin/ && cp /src/jupyter/bmlmodel/notebook_config.yaml /etc/ && pip --no-cache-dir install ipywidgets==7.5.0 -i https://pypi.tuna. tsinghua.edu.cn/simple/ && pip --no-cache-dir install jupyterlab==1.2.6 -i https://pypi.tuna. tsinghua.edu.cn/simple/ && jupyter serverextension enable --py jupyterlab && conda clean -ay && npm cache clean --force && rm -rf $CONDA_DIR/share/jupyter/lab/staging && rm -rf /root/.cache/yarn && rm -rf /root/.node-gyp && rm -rf /src/jupyter ~/.cache ~/.npm EXPOSE 8888 WORKDIR $HOME # Configure container startup ENTRYPOINT ["tini", "--"] CMD ["start-notebook.sh"] # set timezone COPY Shanghai / RUN echo "set timezone" && rm -f /etc/localtime && mv /Shanghai /etc/localtime

制作步骤

  1. 在镜像制作目录下新建 Dockerfile,示例如上
  2. 需要的依赖文件解压后放在同级目录
  3. docker build -t jupyterlab-test:1.0 .

本地验证

  1. docker run -it -p8888:8888 jupyterlab-test:1.0bash
  2. vi /usr/local/bin/jupyter_notebook_config.py 修改为以下两项内容即可 (具体file内容参见dockerfile)
复制代码
1
2
3
c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.open_browser = True
  1. 具体指令 跳转到 jupyter_notebook_config.py 路径下 先执行 jupyter lab 获取token
    运行
    运行 jupyter notebook ,访问展示出来的url地址(127.0.0.1需要替换成物理机ip)
    验证可不可以正常启动,和使用 jupyterlab 界面

最后

以上就是犹豫草莓最近收集整理的关于外部环境构建jupyterlab-notebook镜像的全部内容,更多相关外部环境构建jupyterlab-notebook镜像内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(67)

评论列表共有 0 条评论

立即
投稿
返回
顶部