无法访问 运行 docker 图片时提供的本地主机网址
Can't reach localhost urls provided when running docker images
当我尝试 运行 一个 docker 容器,该容器在脚本或 neo4J docker 图像中使用 os 命令启动 jupyter 时,我遇到了网络问题。我有 ERR_SOCKET_NOT_CONNECTED 或 ERR_CONNECTION_REFUSED
ERR_SOCKET_NOT_CONNECTED
当我 运行 jupyter notebook 时,它似乎在终端中一切正常:
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?
但是 none 的链接有效...我认为这是因为无法从 Docker 图像访问 jupyter。因为当我从有 jupyter 的机器上执行时,我可以访问笔记本:
要求里面有jupyterlab,不知道够不够用:
bash-5.1$ cat requirements.txt
bokeh
jupyterlab
matplotlib
networkx
pandas
scipy
Docker文件确定下载要求:
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"]
所以这似乎是一个网络错误,因为当我尝试从容器的 localhost 移动笔记本时,我仍然有错误“无法访问此站点”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
这是完整的输出:
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
有趣的是,当 运行 使用 neo4j Docker 图像时,我遇到了类似的网络问题,但我无法访问我尝试访问的 neo4j docker 图像 运行:
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.
然后我得到 ERR_CONNECTION_REFUSED
我将测试一个 Django webapp 并添加结果。
可能是 IP 地址有问题?
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
到目前为止我无法访问这些网址,还有其他想法吗?
该卷不安全?
给我留下这张图片的同事告诉我工作目录必须作为卷挂载。
bash-5.1$ docker run -p 8888:8888 -it -e DISPLAY=$DISPLAY -v /home/ac/Documents/Work/serious-game seriousgame:latest
但同样的错误
它似乎服务于正确的目录,对吧?
[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
从外部可见容器端口
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:
IP 地址有问题?
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
您需要将 --ip 0.0.0.0
添加到 jupyter notebook 命令,否则它将服务于容器的本地主机,而您的主机无法访问该本地主机。
还有我的 2 美分:
我强烈建议创建一个 docker-compose 文件来整理东西,build/run 容器很容易,比如:
version: "3.8"
services:
app:
image: seriousgame:latest
build: .
environment:
- DISPLAY=${DISPLAY}
volumes:
- .:/home/serious-game/
- /tmp/.X11-unix:/tmp/.X11-unix
我通常也使用 Makefile,以 make 作为入口,那么您只需 运行 您的 Makefile 目标使用 :
docker-compose run app {serve_bokeh,serve_jupiter,sh}
当我尝试 运行 一个 docker 容器,该容器在脚本或 neo4J docker 图像中使用 os 命令启动 jupyter 时,我遇到了网络问题。我有 ERR_SOCKET_NOT_CONNECTED 或 ERR_CONNECTION_REFUSED
ERR_SOCKET_NOT_CONNECTED
当我 运行 jupyter notebook 时,它似乎在终端中一切正常:
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?
但是 none 的链接有效...我认为这是因为无法从 Docker 图像访问 jupyter。因为当我从有 jupyter 的机器上执行时,我可以访问笔记本:
要求里面有jupyterlab,不知道够不够用:
bash-5.1$ cat requirements.txt
bokeh
jupyterlab
matplotlib
networkx
pandas
scipy
Docker文件确定下载要求:
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"]
所以这似乎是一个网络错误,因为当我尝试从容器的 localhost 移动笔记本时,我仍然有错误“无法访问此站点”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
这是完整的输出:
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
有趣的是,当 运行 使用 neo4j Docker 图像时,我遇到了类似的网络问题,但我无法访问我尝试访问的 neo4j docker 图像 运行:
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.
然后我得到 ERR_CONNECTION_REFUSED
我将测试一个 Django webapp 并添加结果。
可能是 IP 地址有问题?
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
到目前为止我无法访问这些网址,还有其他想法吗?
该卷不安全?
给我留下这张图片的同事告诉我工作目录必须作为卷挂载。
bash-5.1$ docker run -p 8888:8888 -it -e DISPLAY=$DISPLAY -v /home/ac/Documents/Work/serious-game seriousgame:latest
但同样的错误
它似乎服务于正确的目录,对吧?
[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
从外部可见容器端口
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:
IP 地址有问题?
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
您需要将 --ip 0.0.0.0
添加到 jupyter notebook 命令,否则它将服务于容器的本地主机,而您的主机无法访问该本地主机。
还有我的 2 美分: 我强烈建议创建一个 docker-compose 文件来整理东西,build/run 容器很容易,比如:
version: "3.8"
services:
app:
image: seriousgame:latest
build: .
environment:
- DISPLAY=${DISPLAY}
volumes:
- .:/home/serious-game/
- /tmp/.X11-unix:/tmp/.X11-unix
我通常也使用 Makefile,以 make 作为入口,那么您只需 运行 您的 Makefile 目标使用 :
docker-compose run app {serve_bokeh,serve_jupiter,sh}