Issue
When I try to run a docker container that starts jupyter with os command inside a script or a neo4J docker image I have a network issue. I either have ERR_SOCKET_NOT_CONNECTED or ERR_CONNECTION_REFUSED
ERR_SOCKET_NOT_CONNECTED
Whe I run jupyter notebook it seems everything is working right in the terminal:
bash-5.1$ docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix seriousgame:latest
Run bokeh server? ([y]/n)
n
Run jupyter server? ([y]/n)
y
[I 10:14:20.667 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 2021-12-13 10:14:20.942 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-12-13 10:14:20.942 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-12-13 10:14:20.945 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.6/dist-packages/jupyterlab
[I 2021-12-13 10:14:20.945 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 10:14:20.948 NotebookApp] Serving notebooks from local directory: /home/serious-game
[I 10:14:20.948 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 10:14:20.948 NotebookApp] http://localhost:8888/?token=Ihavetohidethis,right?
[I 10:14:20.948 NotebookApp] or http://127.0.0.1:8888/?token=Ihavetohidethis,right?
[I 10:14:20.948 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 10:14:20.950 NotebookApp] No web browser found: could not locate runnable browser.
[C 10:14:20.950 NotebookApp]
To access the notebook, open this file in a browser:
file:///root/.local/share/jupyter/runtime/nbserver-8-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=Ihavetohidethis,right?
or http://127.0.0.1:8888/?token=Ihavetohidethis,right?
But none of the links work ... I think it is because jupyter can't be reached from the Docker image. Because when I did it from the machine where there is jupyter I can access the notebook:
In the requirements there is jupyterlab, I don't know if it is enough:
bash-5.1$ cat requirements.txt
bokeh
jupyterlab
matplotlib
networkx
pandas
scipy
The Dockerfile for sure downloads the requirements:
bash-5.1$ cat Dockerfile
#############################################################################################################
#
# Creation du container
#
##############################################################################################################
FROM nvidia/cuda:10.2-base-ubuntu18.04
MAINTAINER me
EXPOSE 5006
EXPOSE 8888
ENV DEBIAN_FRONTEND noninteractive
ENV WD=/home/serious-game/
WORKDIR ${WD}
# Add git and ssh
RUN apt-get -y update && \
apt-get -y upgrade && \
apt-get -y install git ssh pkg-config python3-pip python3-opencv
# Dépendances python
COPY requirements.txt /requirements.txt
RUN cd / && \
python3 -m pip install --upgrade pip && \
pip3 install -r requirements.txt
RUN ls
COPY start.py /start.py
CMD ["/start.py"]
ENTRYPOINT ["python3"]
So it seems to be a network error because when I tried to move the notebook from the container's localhost I still have the error "This site can’t be reached" ERR_SOCKET_NOT_CONNECTED.
inpt = input("Run jupyter server? ([y]/n) \n")
if inpt.upper() in ["YES", "Y", ""]:
os.system("jupyter-notebook --ip 0.0.0.0 --allow-root")
return
Here is the full output:
bash-5.1$ docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -p 8888:8888 seriousgame:latest
Run bokeh server? ([y]/n)
n
Run jupyter server? ([y]/n)
[I 09:45:21.148 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 2021-12-16 09:45:21.416 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-12-16 09:45:21.416 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2021-12-16 09:45:21.418 LabApp] JupyterLab extension loaded from /usr/local/lib/python3.6/dist-packages/jupyterlab
[I 2021-12-16 09:45:21.419 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 09:45:21.422 NotebookApp] Serving notebooks from local directory: /home/serious-game
[I 09:45:21.422 NotebookApp] Jupyter Notebook 6.4.6 is running at:
[I 09:45:21.422 NotebookApp] http://localhost:8888/?token=addd2ba3162ec37688def2cf63157864cd40b81cf4de42f8
[I 09:45:21.422 NotebookApp] or http://127.0.0.1:8888/?token=addd2ba3162ec37688def2cf63157864cd40b81cf4de42f8
[I 09:45:21.422 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 09:45:21.424 NotebookApp] No web browser found: could not locate runnable browser.
[C 09:45:21.424 NotebookApp]
To access the notebook, open this file in a browser:
file:///root/.local/share/jupyter/runtime/nbserver-8-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=addd2ba3162ec37688def2cf63157864cd40b81cf4de42f8
or http://127.0.0.1:8888/?token=addd2ba3162ec37688def2cf63157864cd40b81cf4de42f8
ERR_CONNECTION_REFUSED
Interestingly, I have a similar network problem with when running a neo4j Docker image I can't reach the neo4j docker image that I tried to run:
bash-5.1$ docker run neo4j
^[[1;5C2021-12-16 09:55:17.973+0000 INFO Starting...
2021-12-16 09:55:18.312+0000 INFO This instance is ServerId{d3a250fb} (d3a250fb-24b6-400d-82d2-5ff00740060f)
2021-12-16 09:55:19.163+0000 INFO ======== Neo4j 4.4.1 ========
2021-12-16 09:55:20.406+0000 INFO Initializing system graph model for component 'security-users' with version -1 and status UNINITIALIZED
2021-12-16 09:55:20.410+0000 INFO Setting up initial user from defaults: neo4j
2021-12-16 09:55:20.411+0000 INFO Creating new user 'neo4j' (passwordChangeRequired=true, suspended=false)
2021-12-16 09:55:20.422+0000 INFO Setting version for 'security-users' to 3
2021-12-16 09:55:20.425+0000 INFO After initialization of system graph model component 'security-users' have version 3 and status CURRENT
2021-12-16 09:55:20.429+0000 INFO Performing postInitialization step for component 'security-users' with version 3 and status CURRENT
2021-12-16 09:55:20.739+0000 INFO Bolt enabled on 0.0.0.0:7687.
2021-12-16 09:55:21.298+0000 INFO Remote interface available at http://localhost:7474/
2021-12-16 09:55:21.300+0000 INFO id: 6A9C435FEE30E82F3EF0611B5D98AB44CCF970739EA66D61896B3C801FA2A2B7
2021-12-16 09:55:21.300+0000 INFO name: system
2021-12-16 09:55:21.301+0000 INFO creationDate: 2021-12-16T09:55:19.614Z
2021-12-16 09:55:21.301+0000 INFO Started.
And I get ERR_CONNECTION_REFUSED
I will test a Django webapp and add the results.
Maybe there is an issue in the IP addr?
bash-5.1$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether d8:bb:c1:79:cc:2e brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 64:6e:e0:f0:32:c3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.178/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp5s0
valid_lft 168207sec preferred_lft 168207sec
inet6 fe80::41c7:dafd:7a6:4f44/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:20:72:95:51 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:20ff:fe72:9551/64 scope link
valid_lft forever preferred_lft forever
10: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
link/none
inet 192.168.254.99/24 brd 192.168.254.255 scope global noprefixroute tun0
valid_lft forever preferred_lft forever
inet6 fe80::7be4:d988:98c1:8551/64 scope link stable-privacy
valid_lft forever preferred_lft forever
18: veth6503edf@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether c2:c7:b8:5f:39:6f brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::c0c7:b8ff:fe5f:396f/64 scope link
valid_lft forever preferred_lft forever
So I can't reach the urls so far, other ideas?
The volume is not the safe one?
The colleague who left me this image tells me that the working directory must be mounted as a volume.
bash-5.1$ docker run -p 8888:8888 -it -e DISPLAY=$DISPLAY -v /home/ac/Documents/Work/serious-game seriousgame:latest
But same error
And it seems it serves the right directory, right?
[I 2021-12-13 10:14:20.945 LabApp] JupyterLab application directory is /usr/local/share/jupyter/lab
[I 10:14:20.948 NotebookApp] Serving notebooks from local directory: /home/serious-game
With the container port visible from the outside
docker run -p 8888:8888 -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix seriousgame:latest
Pero aqui esta lo que me contesta el navigador:
Issues in the IP addr?
bash-5.1$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp3s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
link/ether d8:bb:c1:79:cc:2e brd ff:ff:ff:ff:ff:ff
3: wlp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 64:6e:e0:f0:32:c3 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.178/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp5s0
valid_lft 168207sec preferred_lft 168207sec
inet6 fe80::41c7:dafd:7a6:4f44/64 scope link noprefixroute
valid_lft forever preferred_lft forever
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:20:72:95:51 brd ff:ff:ff:ff:ff:ff
inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
valid_lft forever preferred_lft forever
inet6 fe80::42:20ff:fe72:9551/64 scope link
valid_lft forever preferred_lft forever
10: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 500
link/none
inet 192.168.254.99/24 brd 192.168.254.255 scope global noprefixroute tun0
valid_lft forever preferred_lft forever
inet6 fe80::7be4:d988:98c1:8551/64 scope link stable-privacy
valid_lft forever preferred_lft forever
18: veth6503edf@if17: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default
link/ether c2:c7:b8:5f:39:6f brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet6 fe80::c0c7:b8ff:fe5f:396f/64 scope link
valid_lft forever preferred_lft forever
Solution
You need to add --ip 0.0.0.0
to the jupyter notebook command, or it will serve on the container's localhost, which is not reachable from your host.
Also my 2 cents: I would strongly advise to create a docker-compose file to tidy things up, build/run container easily, with something like :
version: "3.8"
services:
app:
image: seriousgame:latest
build: .
environment:
- DISPLAY=${DISPLAY}
volumes:
- .:/home/serious-game/
- /tmp/.X11-unix:/tmp/.X11-unix
I usually use Makefiles too, with make as ENTRYPOINT, then you only have to run your Makefile target using :
docker-compose run app {serve_bokeh,serve_jupiter,sh}
Answered By - Ludwig
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.