Docker容器如何通过主机上的SSH隧道访问(Mongo-DB)服务
我正在尝试连接到限制对其本地网络访问的远程MONGO-DB实例。因此,我创建了一个SSH隧道,它允许我连接:
ssh -L [端口]:localhost:[hostport] [userName]@[remote -ip]
,但是当我想连接到来自Docker容器的同一Mongo-DB服务连接时间。
我尝试指定一个绑定地址 SO
ssh -L 172.17.0.1.1:[port] host-port] [username]@[remote-ip]
,然后从172.17.0.0.1:facter ot docker容器连接到远程mongo-db,但没有成功。我的错误是什么?
注意:我正在寻找适用于Linux和MAC的解决方案。
I'm trying to connect to a remote mongo-db instance that has restricted access to its local network. So, I create an ssh tunnel, which allows me to connect:
ssh -L [port]:localhost:[hostport] [username]@[remote-ip]
However, when I want to connect to the same mongo-db service from a docker container the connection times out.
I tried to specify a bind address like so
ssh -L 172.17.0.1:[port]:localhost:[host-port] [username]@[remote-ip]
And connect to the remote mongo-db from a docker container at 172.17.0.1:[port], but without success. What's my mistake?
Note: I am looking for a solution that works on both Linux and Mac.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议这样的事情:
在这里,我正在设置一个SSH隧道,可访问遥控器
http代理,然后在另一个容器中访问该代理
在SSH隧道上。这几乎正是您要与MongoDB做的事情。
在真实的环境中,您可能会使用预构建的图像,而不是像我在此示例中那样即时安装软件包。
I am suggesting something like this:
Here I'm setting up an ssh tunnel that provides access to a remote
http proxy, and then in another container I'm accessing that proxy
over the ssh tunnel. This is pretty much exactly what you're looking to do with mongodb.
In a real environment, you would probably be using pre-built images, rather than installing packages on-the-fly as I've done in this example.