Sign inSign up

ddio001/jupyter-lab

By ddio001

•Updated about 5 years ago

自己配jupyter-lab3的镜像

Image
0

1.1K

ddio001/jupyter-lab repository overview

自己打包的jupyter-lab镜像,lab已包含notebook

一般可以使用minimal然后自己安装需要的插件,minimal是基于debian11系统镜像的

⁠minimal镜像信息

打包日期2021-9-15

jupyter-lab版本3.1.12

基于python:3.9.7镜像

使用mirrors.163.com软件源

使用https://pypi.tuna.tsinghua.edu.cn/simplepip源

设置Asia/Shanghai时区

包含jupyter简体中文语言包jupyterlab-language-pack-zh-CN并设为默认语言

⁠参考Dockerfile

FROM python:3.9.7

RUN mkdir /opt/notebooks \
&& chmod -R 777 /opt/notebooks \
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
&& sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
&& sed -i s@/security.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list 

RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
&& pip install jupyterlab --no-cache-dir\
&& jupyter lab --generate-config \
&& chmod -R 777 /root/.jupyter/jupyter_lab_config.py \
&& pip install jupyterlab-language-pack-zh-CN --no-cache-dir\
&& rm -rf ~/.cache/pip \
&& mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension \
&& echo '{"locale": "zh_CN"}' > /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension/plugin.jupyterlab-settings

VOLUME /opt/notebooks
EXPOSE 8888

CMD jupyter lab --notebook-dir=/opt/notebooks --ip='*' --port=8888 --allow-root --no-browser

⁠with-extensions镜像信息

在minimal的基础上安装了许多插件

尽量不要用这个,因为插件太多了。

⁠具体信息参考Dockerfile

#使用python3.9.7源镜像构建
FROM python:3.9.7

#命令执行目录在用户目录
WORKDIR /root

#使用bash执行命令
SHELL ["/bin/bash", "-c"]

#创建笔记本目录
RUN mkdir -p /opt/notebooks \
&& chmod -R 777 /opt/notebooks \
#设置时区
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
#修改镜像源
&& sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
&& sed -i s@/security.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
#更新系统
&& apt update -y \
&& apt upgrade -y \
#安装常用软件包
&& apt install -y dialog apt-utils vim curl wget \
#安装latex相关软件包
&& apt install -y chktex pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic \
#安装nodejs最新lts版
&& curl -fsSL https://deb.nodesource.com/setup_lts.x | bash \
&& apt install -y nodejs \
#配置nodejs
&& npm -g config set user root \
&& npm config set registry https://registry.npm.taobao.org \
&& npm config set disturl https://npm.taobao.org/dist --global \
#安装texlab(latex相关)
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& source /root/.cargo/env \
&& cargo install --git https://hub.fastgit.org/latex-lsp/texlab.git --locked \
#配置pip国内源 
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
#清理apt缓存
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

#安装jupyterlab最新版并生成配置
RUN pip install jupyterlab \
&& jupyter lab --generate-config \
&& chmod -R 777 /root/.jupyter/jupyter_lab_config.py \
#安装中文语言包并设置为当前语言
&& pip install jupyterlab-language-pack-zh-CN \
&& mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension \
&& echo '{"locale": "zh_CN"}' > /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension/plugin.jupyterlab-settings \
#安装jupyterlab的js支持(因为nodejs都装上了就顺便装上这个)
&& npm install -g ijavascript \
&& ijsinstall \
#安装语言补齐功能
&& pip install jupyterlab-lsp \
&& pip install python-lsp-server[all] \
&& jlpm add --dev \
    bash-language-server \
    vscode-css-languageserver-bin \
    dockerfile-language-server-nodejs \
    vscode-html-languageserver-bin \
    javascript-typescript-langserver \
    vscode-json-languageserver-bin \
##&& npm install -g --save-dev javascript-typescript-langserver \
##&& npm install -g --save-dev bash-language-server \
##&& npm install -g --save-dev dockerfile-language-server-nodejs \
&& npm install --save-dev unified-language-server \
##& npm install -g --save-dev vscode-css-languageserver-bin \
##&& npm install -g --save-dev vscode-html-languageserver-bin \
&& npm install --save-dev yaml-language-server \
&& npm install --save-dev sql-language-server \ 
#↑这个包容易装不上
#安装代码格式化工具
&& pip install jupyterlab-code-formatter black isort yapf autopep8 \
#安装执行区块执行时间提示工具
&& pip install jupyterlab-execute-time \
&& mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/notebook-extension \
&& echo '{"recordTiming": true}' > /root/.jupyter/lab/user-settings/@jupyterlab/notebook-extension/tracker.jupyterlab-settings \
#安装区块执行完成闪烁工具
&& pip install jupyterlab-cell-flash \
#安装主题
&& pip install theme-darcula jupyterlab-horizon-theme jupyterlab-simpledark jupyterlab_materialdarker \
#安装把编辑器变为vim编辑器的插件并设置为关闭
&& pip install jupyterlab-vim \
&& jupyter labextension disable --no-build @axlair/jupyterlab_vim \
#安装拼写检查工具并下载词典
&& pip install jupyterlab-spellchecker \
&& mkdir -p /root/.local/share/jupyter/dictionaries/ \
&& wget -O /root/.local/share/jupyter/dictionaries/en_US.dic https://cdn.jsdelivr.net/gh/LibreOffice/dictionaries@master/en/en_US.dic \
&& wget -O /root/.local/share/jupyter/dictionaries/en_US.aff https://cdn.jsdelivr.net/gh/LibreOffice/dictionaries@master/en/en_US.aff \
&& mkdir -p /root/.jupyter/lab/user-settings/@ijmbarr/jupyterlab_spellchecker \
&& echo '{"language": "en_US"}' > /root/.jupyter/lab/user-settings/@ijmbarr/jupyterlab_spellchecker/plugin.jupyterlab-settings \
#安装git工具
&& pip install jupyterlab-git jupyterlab-pullrequests \
#安装latex支持工具
&& npm install -g --save-dev tectonic \
&& pip install jupyterlab-latex jupyterlab-katex \
#安装显卡资源监视工具
&& pip install jupyterlab-nvdashboard \
#安装系统资源监视工具
&& pip install jupyterlab-system-monitor \
#安装文本对比工具
&& pip install jupytext \
#安装一些小工具
&& pip install jupyter-archive jupyterlab-notebookbuttons jupyterlab-link-share jupyterlab-favorites jupyterlab-recents \
#安装一些画图库
&& pip install jupyter-dash jupyter-bokeh jupyterlab-drawio ipympl algorithmx \
&& pip install jupyterlab-fasta jupyterlab-geojson jupyterlab-mathjax3 jupyterlab-vega2 jupyterlab-vega3 \
#安装jupyterlab定制化工具
&& pip install ipylab ipywidgets jupyterlab-widgets sidecar jupyterlab-commands ipygoldenlayout \
#安装高级变量查看器
&& pip install pandas lckr-jupyterlab-variableinspector \
#给jupyterlab提供webin/out功能
&& pip install webio-jupyterlab-provider \
#把notebook变成web应用,但是我不会用
&& pip install voila \
#一套画图工具和依赖
&& pip install numpy traitlets traittypes bqplot \
#给js和py提供通信支持
&& pip install pyviz_comms \
#jupyterlab高级工具
&& pip install jupyter_starters \
#一个高级互动作图工具
&& pip install ipyelk \
#集群软件
&& pip install dask[complete] dask-labextension \
#给jupyterlab提供旧版视图
&& pip install nbclassic retrolab \
#jupyter主题基础库
&& pip install cookiecutter \
#一个互动绘制库
&& npm install -g --save-dev lumino \
#内核查看器
&& pip install jupyterlab-kernelspy \
#顶部工具栏
&& pip install jupyterlab-topbar jupyterlab-logout \
#下载按钮
&& pip install jupyter-offlinenotebook \
#单个区块小按钮,装了可能导致相应变慢
&& pip install jlab-enhanced-cell-toolbar \
#下面的不知道干什么的
&& pip install etc-jupyterlab-notebook-state-provider etc-jupyterlab-telemetry-library \
#csv编辑器
&& pip install jupyterlab-spreadsheet-editor \
#安装自定义库
&& pip install tqdm \
 scikit-learn \
 PyMySQL \
 scipy \
 sympy \
 sklearn \
&& jupyter labextension install --no-build jupyterlab-tailwind-theme \
&& jupyter labextension install --no-build @jupyterlab/toc \
&& jupyter labextension install --no-build @jupyterlab/debugger \
&& jupyter labextension install --no-build @krassowski/jupyterlab_go_to_definition \
&& jupyter labextension install --no-build jupyterlab-spreadsheet \
&& jupyter labextension install --no-build @techrah/text-shortcuts \
&& jupyter labextension install jupyterlab-topbar-text \
&& jupyter lab clean \
&& jupyter lab build --dev-build=False --minimize=False \
&& npm cache clean -f \
&& rm -rf ~/.cache/pip

VOLUME /opt/notebooks
EXPOSE 8888

CMD jupyter lab --notebook-dir=/opt/notebooks --ip='*' --port=8888 --allow-root --no-browser

⁠with-other-languages镜像信息

在with-extensions的基础上增加了对R,Julia,Lua语言的支持

Dockerfile多了一层RUN

RUN apt update -y \
&& apt install -y r-base r-base-dev julia lua5.4 \
&& mkdir -p /root/.julia/config \
&& echo 'ENV["JULIA_PKG_SERVER"] = "https://mirrors.bfsu.edu.cn/julia"' > /root/.julia/config/startup.jl \
&& echo -e "options(repos=structure(c(CRAN='https://mirrors.tuna.tsinghua.edu.cn/CRAN/')))\n\
install.packages('IRkernel')\n\
IRkernel::installspec(user = FALSE)\n\
install.packages('languageserver')" > /root/iirk.R \
&& Rscript /root/iirk.R \
&& rm -f /root/iirk.R \
&& echo -e 'using Pkg;Pkg.add("IJulia");Pkg.add("LanguageServer");' > /root/iijk.jl \
&& julia /root/iijk.jl \
&& echo -e 'using Pkg;Pkg.add("Statistics");Pkg.add("StatsBase");Pkg.add("Plots");Pkg.add("GR");Pkg.add("Gadfly");Pkg.add("PyPlot");Pkg.add("DelimitedFiles");Pkg.add("CSV");Pkg.add("JLD2");Pkg.add("DataFrames");Pkg.add("RDatasets");Pkg.add("Distributions");Pkg.add("MultivariateStats");Pkg.add("MLBase");Pkg.add("DecisionTree");Pkg.add("LIBSVM");Pkg.add("GLM");Pkg.add("Clustering");Pkg.add("TimeSeries");Pkg.add("PyCall");Pkg.add("Arpack");Pkg.add("TensorOperations");Pkg.add("NLopt");Pkg.add("Pajarito");Pkg.add("MathProgBase");Pkg.add("GLPKMathProgInterface");Pkg.add("LinQuadOptInterface");Pkg.add("SemidefiniteOptInterface");Pkg.add("ConicBenchmarkUtilities");Pkg.add("SemidefiniteModels");Pkg.add("MathOptInterfaceMosek");' > /root/iijk.jl \
&& julia /root/iijk.jl \
&& rm -f /root/iijk.jl \
&& pip install ilua \
&& rm -rf ~/.cache/pip \
&& jupyter lab build --dev-build=False \
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

⁠运行方式

docker run -d --name jupyterlab3 -p 8888:8888 -v YOUR_FILE_PATH:/opt/notebooks ddio001/jupyter-lab:minimal

启动成功后使用

docker logs 容器id/容器名

查看容器日志,并从中复制出token来登录或设置密码

[I 2021-09-15 09:44:04.346 ServerApp] jupyterlab | extension was successfully loaded.
[I 2021-09-15 09:44:04.350 ServerApp] Serving notebooks from local directory: /opt/notebooks
[I 2021-09-15 09:44:04.350 ServerApp] Jupyter Server 1.11.0 is running at:
[I 2021-09-15 09:44:04.350 ServerApp] http://0d51105c5d01:8888/lab?token=b11350706f9d901be9199080568928b47f4ea48f1de3c1c4
[I 2021-09-15 09:44:04.350 ServerApp]  or http://127.0.0.1:8888/lab?token=b11350706f9d901be9199080568928b47f4ea48f1de3c1c4

访问http://ip:8888/lab以使用jupyter-lab

访问http://ip:8888/tree以使用jupyter-notebook

你还可以登录容器终端或在jupyter-lab里打开终端并使用jupyter lab password设置密码

⁠附 for-myself镜像仅供自己使用

贴出Dockerfile供参考

#使用python3.9.7源镜像构建
FROM python:3.9.7

#命令执行目录在用户目录
WORKDIR /root

#使用bash执行命令
SHELL ["/bin/bash", "-c"]

#创建笔记本目录
RUN mkdir -p /opt/notebooks \
&& chmod -R 777 /opt/notebooks \
#设置时区
&& ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
#修改镜像源
&& sed -i s@/deb.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
&& sed -i s@/security.debian.org/@/mirrors.163.com/@g /etc/apt/sources.list \
#更新系统
&& apt update -y \
&& apt upgrade -y \
#安装常用软件包
&& apt install -y dialog apt-utils vim curl wget \
#安装latex相关软件包
&& apt install -y chktex pandoc texlive-xetex texlive-fonts-recommended texlive-plain-generic \
#安装nodejs最新lts版
&& curl -fsSL https://deb.nodesource.com/setup_lts.x | bash \
&& apt install -y nodejs \
#配置nodejs
&& npm -g config set user root \
&& npm config set registry https://registry.npm.taobao.org \
&& npm config set disturl https://npm.taobao.org/dist --global \
#安装texlab(latex相关)
&& curl https://sh.rustup.rs -sSf | sh -s -- -y \
&& source /root/.cargo/env \
&& cargo install --git https://hub.fastgit.org/latex-lsp/texlab.git --locked \
#配置pip国内源 
&& pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple \
#清理apt缓存
&& apt clean \
&& rm -rf /var/lib/apt/lists/*

#安装jupyterlab最新版并生成配置
RUN pip install jupyterlab \
&& jupyter lab --generate-config \
&& chmod -R 777 /root/.jupyter/jupyter_lab_config.py \
#安装中文语言包并设置为当前语言
&& pip install jupyterlab-language-pack-zh-CN \
&& mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension \
&& echo '{"locale": "zh_CN"}' > /root/.jupyter/lab/user-settings/@jupyterlab/translation-extension/plugin.jupyterlab-settings \
#安装jupyterlab的js支持(因为nodejs都装上了就顺便装上这个)
&& npm install -g ijavascript \
&& ijsinstall \
#安装语言补齐功能
&& pip install jupyterlab-lsp \
&& pip install python-lsp-server[all] \
&& jlpm add --dev \
    bash-language-server \
    vscode-css-languageserver-bin \
    dockerfile-language-server-nodejs \
    vscode-html-languageserver-bin \
    javascript-typescript-langserver \
    vscode-json-languageserver-bin \
&& npm install --save-dev unified-language-server \
&& npm install --save-dev yaml-language-server \
&& npm install --save-dev sql-language-server \ 
#↑这个包容易装不上
#安装代码格式化工具
&& pip install jupyterlab-code-formatter black isort \
#安装执行区块执行时间提示工具
&& pip install jupyterlab-execute-time \
&& mkdir -p /root/.jupyter/lab/user-settings/@jupyterlab/notebook-extension \
&& echo '{"recordTiming": true}' > /root/.jupyter/lab/user-settings/@jupyterlab/notebook-extension/tracker.jupyterlab-settings \
#安装区块执行完成闪烁工具
&& pip install jupyterlab-cell-flash \
#安装主题
&& pip install theme-darcula jupyterlab-horizon-theme jupyterlab-simpledark jupyterlab_materialdarker \
#安装拼写检查工具并下载词典
&& pip install jupyterlab-spellchecker \
&& mkdir -p /root/.local/share/jupyter/dictionaries/ \
&& wget -O /root/.local/share/jupyter/dictionaries/en_US.dic https://cdn.jsdelivr.net/gh/LibreOffice/dictionaries@master/en/en_US.dic \
&& wget -O /root/.local/share/jupyter/dictionaries/en_US.aff https://cdn.jsdelivr.net/gh/LibreOffice/dictionaries@master/en/en_US.aff \
&& mkdir -p /root/.jupyter/lab/user-settings/@ijmbarr/jupyterlab_spellchecker \
&& echo '{"language": "en_US"}' > /root/.jupyter/lab/user-settings/@ijmbarr/jupyterlab_spellchecker/plugin.jupyterlab-settings \
#安装git工具
&& pip install jupyterlab-git jupyterlab-pullrequests \
#安装latex支持工具
&& npm install -g --save-dev tectonic \
&& pip install jupyterlab-latex jupyterlab-katex \
#安装系统资源监视工具
&& pip install jupyterlab-system-monitor \
#安装文本对比工具
&& pip install jupytext \
#安装一些小工具
&& pip install jupyter-archive jupyterlab-notebookbuttons jupyterlab-link-share jupyterlab-favorites jupyterlab-recents \
#安装jupyterlab定制化工具
&& pip install ipylab ipywidgets jupyterlab-widgets sidecar jupyterlab-commands ipygoldenlayout \
#给js和py提供通信支持
&& pip install pyviz_comms \
#jupyterlab高级工具
&& pip install jupyter_starters \
#jupyter主题基础库
&& pip install cookiecutter \
#顶部工具栏
&& pip install jupyterlab-topbar jupyterlab-logout \
#csv编辑器
&& pip install jupyterlab-spreadsheet-editor \
#安装自定义库
&& pip install numpy \
 tqdm \
 scikit-learn \
 PyMySQL \
 scipy \
 sympy \
 sklearn \
#↓没见到什么效果
&& jupyter labextension install --no-build jupyterlab-tailwind-theme \
&& jupyter labextension install jupyterlab-topbar-text \
&& jupyter lab clean \
&& jupyter lab build --dev-build=False --minimize=False \
&& npm cache clean -f \
&& rm -rf ~/.cache/pip

VOLUME /opt/notebooks
EXPOSE 8888

CMD jupyter lab --notebook-dir=/opt/notebooks --ip='*' --port=8888 --allow-root --no-browser

Tag summary

Content type

Image

Digest

Size

376.5 MB

Last updated

about 5 years ago

docker pull ddio001/jupyter-lab