Search code examples
mongodbsshdockerdocker-composedocker-machine

How to do SSH tunneling with docker (machine & compose)?


I have a mongoDB container running on an instance built with docker-machine, maintained with docker-compose. The mongoDB process isn't exposed to external traffic.

I want to connect to the remote mongoDB server using a GUI tool installed locally and without exposing any ports on the remote machine.

What's the best way to do this? Is there any way I can tunnel the connection via ssh with the docker-machinie ssh command?


Solution

  • What's the best way to do this? Is there any way I can tunnel the connection via ssh with the docker-machinie ssh command?

    Yes. Per the docs, docker-machine invokes the standard OpenSSH client. You can use the same -L syntax that you'd normally use for SSH tunneling. The end of the doc has an example using port 8080.