gpt4 book ai didi

python - tornado/graphlab 无法在 docker 中分配请求的地址

转载 作者:行者123 更新时间:2023-11-28 21:04:29 24 4
gpt4 key购买 nike

运行 gl.canvas.set_target('ipynb') 会在 docker 容器中抛出以下异常。

即使使用 gl.canvas.set_target('ipynb', port=28892),其中 28892 是一个开放端口,错误仍然存​​在。

---------------------------------------------------------------------------
error Traceback (most recent call last)
<ipython-input-257-3f215a521352> in <module>()
----> 1 gl.canvas.set_target('ipynb')

/opt/conda/envs/gl-env/lib/python2.7/site-packages/graphlab/canvas/utils.pyc in set_target(target, port)
102 # and to preserve backwards compatibility/other use cases
103 # (running a notebook exported to .py, for instance)
--> 104 _active_target = targets[target]()
105
106 # track metrics on target

/opt/conda/envs/gl-env/lib/python2.7/site-packages/graphlab/canvas/target.pyc in __init__(self, port)
25 self.state = graphlab.canvas.state.State()
26 # TODO server is not necessary in static IPython/Jupyter Notebook
---> 27 self.server = graphlab.canvas.server.Server(self.state, port)
28 # add data objects to left nav
29 DataView = graphlab.canvas.views.data_objects.DataObjectsView()

/opt/conda/envs/gl-env/lib/python2.7/site-packages/graphlab/canvas/server.pyc in __init__(self, state, port)
44
45 #Will raise exception if port cannot be bound
---> 46 self.__bind_socket(port)
47
48 # methods

/opt/conda/envs/gl-env/lib/python2.7/site-packages/graphlab/canvas/server.pyc in __bind_socket(self, port)
93 # Raises exception if socket cannot be bound on requested port
94 def __bind_socket(self, port=None):
---> 95 sockets = tornado.netutil.bind_sockets(port,"localhost")
96 self.__server.add_sockets(sockets)
97 with self.__port_lock:

/opt/conda/envs/gl-env/lib/python2.7/site-packages/tornado/netutil.pyc in bind_sockets(port, address, family, backlog, flags, reuse_port)
194
195 sock.setblocking(0)
--> 196 sock.bind(sockaddr)
197 bound_port = sock.getsockname()[1]
198 sock.listen(backlog)

/opt/conda/envs/gl-env/lib/python2.7/socket.pyc in meth(name, self, *args)
226
227 def meth(name,self,*args):
--> 228 return getattr(self._sock,name)(*args)
229
230 for _m in _socketmethods:

error: [Errno 99] Cannot assign requested address

它看起来更像是 docker/tornado 问题而不是 graphlab 问题,因为在主机中相同的命令有效。

我使用以下命令启动了我的 docker 容器:

sudo docker run -it -v /path/to/data:/root/data \
-v ~/code/work/src:/root/src \
-p 8888:8888 -p 28892:28892 company/graphlab \
/bin/bash -c "source activate gl-env && jupyter notebook --notebook-dir=~/src --ip='*' --port=8888 --no-browser"

有没有办法找出这个端口以便我可以打开它或任何其他方法来解决这个问题?

最佳答案

编辑您的/etc/hosts 文件(在容器内)以仅包含本地主机的 1 个 ip 地址值为我解决了这个问题。它仅在您在运行的容器上编辑它时才有效。在构建图像时对其进行编辑并不能解决问题。

从容器启动时,我的/etc/hosts 有以下行:

127.0.0.1   localhost
::1 localhost ip6-localhost ip6-loopback

我必须将它们更改为:

127.0.0.1   localhost
::1 ip6-localhost ip6-loopback

关于python - tornado/graphlab 无法在 docker 中分配请求的地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45342459/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com