title: Access service on host machine from docker container
body: <p>I've asked a similar question on the docker forum...</p>
  
  <p><a href="https://forums.docker.com/t/access-service-on-host-machine-from-docker-container/45117" rel="nofollow noreferrer">https://forums.docker.com/t/access-service-on-host-machine-from-docker-container/45117</a></p>
  
  <p>...but I'm not getting any joy and this should not be difficult. However when I google about it seems that it is difficult which seems crazy to me. So I'll ask the question in a different way...</p>
  
  <p><strong>Host A</strong> running docker <strong>container A</strong> </p>
  
  <p><strong>Host B</strong> running a <strong>legacy service</strong> exposed on <strong>port 1234</strong></p>
  
  <p><strong>container A</strong> can access the <strong>legacy service</strong> on <strong>host B</strong> on <strong>port 1234</strong> (no problems)</p>
  
  <p>Now I decide to run <strong>container A</strong> on <strong>host B</strong>. The crazy thing is <strong>container A</strong> can no longer access the legacy service provided by <strong>host B</strong> no matter what I try!</p>
  
  <p>There must be a way to do this reliably?</p>
  
  <p><strong>Container A</strong> can ping <strong>host B</strong> fine when running on <strong>host A or B</strong> but when container A tries to connect to the legacy service I always get the error</p>
  
  <blockquote>
    <p>No route to host</p>
  </blockquote>
  
  <p>There is no firewalls (they have been disabled) and dns works fine within container A and resolves host B to the correct IP no matter what host it is running on.</p>