【问题标题】:Enable jupyterlab extensions by default via docker默认通过 docker 启用 jupyterlab 扩展
【发布时间】:2021-04-11 20:45:18
【问题描述】:

我通过 Dockerfile 启动了 jupyterlab 3,其中包含一些扩展名,例如 mathjax3-extension。如果我运行它,我需要在扩展工作之前先启用扩展管理器,例如乳胶被渲染。有没有办法包含一个 Docker 命令来默认启用扩展管理器?我找到了这个here,但无法将其转换为 Docker 命令。

【问题讨论】:

    标签: docker jupyter-lab


    【解决方案1】:

    您可以在~/.jupyter/jupyter_notebook_config.py 的用户目录中放置一个预构建的设置文件,或者在/etc/jupyter/jupyter_notebook_config.py 中设置系统范围的默认值。

    有关示例实现,请参阅jupyter project's base-notebook docker image,它通过复制您可以在根目录中查看的jupyter_notebook_config.py 文件来设置系统默认值。

    然后这个文件被复制到within the dockerfile (L155):

    # Currently need to have both jupyter_notebook_config and jupyter_server_config to support classic and lab
    COPY jupyter_notebook_config.py /etc/jupyter/
    

    【讨论】:

    • 谢谢,我需要先研究图像,知道如何操作它,但似乎是这样。
    【解决方案2】:

    Jupyter Lab 有一个设置文件,用于检查您是否已阅读有关扩展的警告并同意启用它们。您需要添加此文件。

    在 docker 中添加一行:

    COPY ./plugin.jupyterlab-settings /home/$USER/.jupyter/lab/user-settings/@jupyterlab/extensionmanager-extension/
    

    以上命令假设:

    1. $USER 假定在您的 dockerfile 中早先定义。

    2. plugin.jupyterlab-settings是一个文件,内容如下:

      {
          // Extension Manager
          // @jupyterlab/extensionmanager-extension:plugin
          // Extension manager settings.
          // *********************************************
      
          // Disclaimed Status
          // Whether the user understand that extensions managed through this interface run arbitrary code that may be dangerous
          "disclaimed": true
      }
      

    【讨论】:

      猜你喜欢
      • 2021-07-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多