title: Docker connect to server on host machine
body: <p>Say on the host machine I have a server running on <code>localhost:4000</code>. How do I connect to that server from inside a Docker container?</p>
  
  <p>This is a security risk in some cases, but in my case, this is running on my personal machine, so I can give the container all the privileges it needs to talk with the host machine.</p>
  
  <p>For example in the Docker container, if I run:</p>
  
  <pre><code>RUN nc localhost 4000 | xargs echo
  </code></pre>
  
  <p>I don't think that's going to to be able to connect to the server running on the host, unless I take some extra steps.</p>