Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running Jupyter Notebook from Docker: curl: (56) Recv failure: Connection reset by peer

I have a simple 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"]

I build it and launch a container like this:

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

Then I check the logs to get the jupyter login token:

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

So then I try to curl the link, but I get this:

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

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

If I run a docker container exec -it test_run bash and run the curl from there, it's working

Running netstat -tupln on the host:

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

Running netstat -tupln in the container:

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

Any tips?

like image 908
Zac R. Avatar asked Jan 26 '23 10:01

Zac R.


1 Answers

Changed the --ip=127.0.0.1 to --ip=0.0.0.0 and it solved my problems..

like image 180
Zac R. Avatar answered Jan 29 '23 08:01

Zac R.