运行 Docker 中的 Raku 笔记本

Running Raku notebook in Docker

运行 Raku (previously aka Perl 6) kernel 在 Jupyter notebook 中对于重现性和易用性来说会很好(个人观点)。

我想 运行 Perl 6 notebook in a docker container and access it in my web browser. For this I created this docker image

创建 docker 图像的代码是:

FROM sumankhanal/rakudo:2019.07.1

RUN apt-get update \
    && apt-get install -y ca-certificates python3-pip && pip3 install jupyter notebook \
    && zef install Jupyter::Kernel --force-test

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"]

我在 Windows 10 64 bit,我 docker 的 IP 地址是 192.168.99.100

当我尝试使用此代码 运行 容器时:

docker run -it -p 8888:8888 sumankhanal/raku-notebook 在 docker 终端

我收到这个错误:

$ docker run -it -p 8888:8888 sumankhanal/raku-notebook
[I 14:26:43.598 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
  File "/usr/local/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/usr/local/lib/python3.5/dist-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py", line 1296, in initialize
    self.init_webapp()
  File "/usr/local/lib/python3.5/dist-packages/notebook/notebookapp.py", line 1120, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/usr/local/lib/python3.5/dist-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/lib/python3.5/dist-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

有什么帮助吗?

您需要在 Dockerfile 的 CMD 中添加 --allow-root。您还需要 link dockerfile 中带有 jupyter 的内核

jupyter-kernel.p6 --generate-config

完成后,您将能够看到 dockerfile。我还注意到你的图像非常大,你应该尝试为 jupyter 找到一个更好的基础图像而不是你现有的图像。

有关安装内核的更多详细信息,请参阅下面link

https://jupyter.readthedocs.io/en/latest/install-kernel.html