我对Docker非常满意,如果这很明显,请原谅我。
我有两个要聊天的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)"
]
]
}
所以我不确定 一种。我使用正确的URL来访问服务器,并且 b。我需要进行更多设置才能让他们交谈。
我正在Windows上运行docker。我可以设置一个ubuntu VM来运行它们,但这似乎很多余。任何帮助表示赞赏。
答案 0 :(得分:0)
尝试使用gremlin_url ='ws://host.docker.internal:8182 / gremlin'或其他docker容器主机名代替gremlin_url ='ws:// localhost:8182 / gremlin'。