【问题标题】:Running Jupyter Notebook from Docker: curl: (56) Recv failure: Connection reset by peer从 Docker 运行 Jupyter Notebook: curl: (56) Recv failure: Connection reset by peer
【发布时间】:2019-09-06 02:30:45
【问题描述】:

我有一个简单的 Dockerfile

FROM ubuntu:latest

RUN pip install cython jupyter

EXPOSE 8888 4040

CMD ["jupyter", "notebook", "--ip=127.0.0.1", "--port=8888", "--allow-root", "--no-browser"]

我构建它并像这样启动一个容器:

docker container run -d -p 8888:8888 -p 4040:4040 --name test_run my_custom_image

然后我检查日志以获取 jupyter 登录令牌:

docker container logs test_run
...
Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://127.0.0.1:8888/?token=7bf22f85e7b942b9936b1403523ba8c334a62bdd278376fc

然后我尝试卷曲链接,但我明白了:

curl http://127.0.0.1:8888/tree?token=7bf22f85e7b942b9936b1403523ba8c334a62bdd278376fc

curl: (56) Recv failure: Connection reset by peer

如果我运行 docker container exec -it test_run bash 并从那里运行 curl,它就可以工作

在主机上运行netstat -tupln

tcp6       0      0 :::8888                 :::*                    LISTEN      

在容器中运行netstat -tupln

tcp        0      0 127.0.0.1:8888          0.0.0.0:*               LISTEN      1/python

有什么建议吗?

【问题讨论】:

    标签: docker jupyter-notebook


    【解决方案1】:

    --ip=127.0.0.1 更改为--ip=0.0.0.0,它解决了我的问题..

    【讨论】:

    • 谢谢,这也是我的解决方案
    • 太棒了。谢谢!我的猜测是 HTTP 请求被转发到内部 docker IP 并且 jupyter 拒绝它,因为它只侦听 localhost。 0.0.0.0 基本上删除了该检查(它只是意味着“任何 IP”)
    猜你喜欢
    • 2014-12-20
    • 2021-05-11
    • 2021-09-06
    • 1970-01-01
    • 2012-07-15
    • 1970-01-01
    • 2019-06-11
    • 2020-06-06
    • 1970-01-01
    相关资源
    最近更新 更多