Docker connect to remote box through host port forwarding

dockerport-forwarding

So, i have a Docker container with an app that needs to connect to Redis instance on remote machine. There is no direct connection to that Redis host from Docker container or from Docker host, but i can establish port forwarding from Docker host to that Redis box.

Port forwarding established on Docker host: ssh -L 8810:REDIS_HOST:6379 someUser@someHost

Docker Container (App) -> requests to localhost:8810 or to DOCKER_HOST_IP:8810 
isn't forwarded to REDIS_HOST.

Do i need to modify somehow DOCKER_HOST port forwarding or it's hosts file to make that work?

Best Answer

It turns out that you need to add -g to SSH port forwarding and then use DOCKER_HOST ip to make requests from App in the container

Related Topic