title: access host's ssh tunnel from docker container
body: <p>Using ubuntu tusty, there is a service running on a remote machine, that I can access via port forwarding through an ssh tunnel from <code>localhost:9999</code>.</p>
  
  <p>I have a docker container running. I need to access that remote service via the host's tunnel, from within the container.</p>
  
  <p>I tried tunneling from the container to the host with <code>-L 9000:host-ip:9999</code> , then accessing the service through <code>127.0.0.1:9000</code> from within the container fails to connect. To check wether the port mapping was on, I tried
  <code>
  nc -luv -p 9999 # at host
  nc -luv -p 9000 # at container
  </code></p>
  
  <p>following <a href="http://www.binarytides.com/netcat-tutorial-for-beginners/" rel="noreferrer">this, parag. 2</a> but there was no perceived communication, even when doing 
  <code>
  nc -luv host-ip -p 9000
  </code>  at the container</p>
  
  <p>I also tried mapping the ports via <code>docker run -p 9999:9000</code> , but this reports that the bind failed because the host port is already in use (from the host tunnel to the remote machine, presumably).</p>
  
  <p>So my questions are</p>
  
  <p>1 - How will I achieve the connection?  Do I need to setup an ssh tunnel to the host, or can this be achieved with the docker port mapping alone?</p>
  
  <p>2 - What's a quick way to test that the connection is up? Via bash, preferably.</p>
  
  <p>Thanks.</p>