我对Docker有点新手,所以如果这是显而易见的,请原谅我。
我有两个码头集装箱,我想和他们谈谈。一种是开箱即用地运行gremlin-server实例。我是从命令docker run --name="gremlin-server" -p 8182:8182 tinkerpop/gremlin-server开始的
另一个是使用lambci运行一个lambda函数。要运行我的基本测试函数,我使用命令docker run --rm -v "$PWD"/lambda:/var/task -v "$PWD"/layer:/opt lambci/lambda:python3.6 test_containers.lambda_handler
下面是我的test_containers.py代码:
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.anonymous_traversal import traversal
def lambda_handler(event, context):
gremlin_url = 'ws://localhost:8182/gremlin'
g = traversal().withRemote(DriverRemoteConnection(gremlin_url, 'g'))下面是我从lambda函数返回的错误:
{
"errorMessage":"[Errno 99] Cannot assign requested address",
"errorType":"OSError",
"stackTrace":[
[
"/var/task/test_containers.py",
7,
"lambda_handler",
"g = traversal().withRemote(DriverRemoteConnection(gremlin_url, 'g'))"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/driver_remote_connection.py",
45,
"__init__",
"password=password)"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/client.py",
76,
"__init__",
"self._fill_pool()"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/client.py",
92,
"_fill_pool",
"conn = self._get_connection()"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/client.py",
105,
"_get_connection",
"self._transport_factory, self._executor, self._pool)"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/connection.py",
40,
"__init__",
"self.connect()"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/connection.py",
46,
"connect",
"self._transport.connect(self._url)"
],
[
"/opt/python/lib/python3.6/site-packages/gremlin_python/driver/tornado/transport.py",
33,
"connect",
"lambda: websocket.websocket_connect(url))"
],
[
"/opt/python/lib/python3.6/site-packages/tornado/ioloop.py",
458,
"run_sync",
"return future_cell[0].result()"
],
[
"/opt/python/lib/python3.6/site-packages/tornado/concurrent.py",
238,
"result",
"raise_exc_info(self._exc_info)"
],
[
"<string>",
4,
"raise_exc_info",
""
],
[
"/opt/python/lib/python3.6/site-packages/tornado/iostream.py",
1117,
"connect",
"self.socket.connect(address)"
]
]
}所以我不确定a.我是否使用了正确的url来访问服务器,b.我需要做更多的设置才能让他们说话。
我在windows上运行docker。我可以设置一个ubuntu虚拟机来运行它们,但这似乎...多余的。任何帮助都是非常感谢的。
发布于 2019-06-07 16:46:29
不是gremlin_url = 'ws://localhost:8182/gremlin‘,而是gremlin_url = 'ws://host.docker.internal:8182/gremlin’或您的docker容器主机名。
https://stackoverflow.com/questions/54488396
复制相似问题