我可以让 Jupyter 从 docker 容器中正常工作,甚至可以让 Jupyter 扩展在 docker 容器中工作(如果它们是jupyter_contrib_nbextensions的一部分) ,但我无法让jupyter-black扩展在 docker 容器中工作。
这就是我正在尝试的。我有一个Dockerfile
看起来像这样的:
FROM python:3.8-slim-buster
WORKDIR /usr/src/app
RUN pip install black jupyter
# Jupyter black installation as mentioned at the bottom of
# https://github.com/drillan/jupyter-black
RUN jupyter nbextension install https://github.com/drillan/jupyter-black/archive/master.zip --user
RUN jupyter nbextension enable jupyter-black-master/jupyter-black
# Add Tini. Tini operates as a process subreaper for jupyter. This prevents
# kernel crashes.
ENV TINI_VERSION v0.6.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /usr/bin/tini
RUN chmod +x /usr/bin/tini
ENTRYPOINT ["/usr/bin/tini", "--"]
EXPOSE 8888
CMD ["jupyter", "notebook", "--port=8888", "--no-browser", "--ip=0.0.0.0", "--allow-root"]
从与该目录相同的目录中Dockerfile
,我运行docker build . -t myjupyter
,然后docker run -p 8888:8888 -it --rm myjupyter
,然后打开它提供的包含令牌的 jupyter notebook 链接。当我打开一个新笔记本时,我希望看到这个黑色按钮,当我直接在我的机器上安装这个包时会看到这个按钮,但是当我按照我的描述从 docker 运行时,那个按钮就不见了。
从简单的 docker 容器为 jupyter 笔记本启用黑色格式的最佳方法是什么?我应该考虑完全不同的库,还是只是安装和启用我已经尝试的库的不同方式?