title: Docker cannot access exposed port inside container
body: <p>I have a container for which I expose my port to access a service running within the container. I am not exposing my ports outside the container i.e. to the host (using host network on mac). On getting inside the container using <code>exec -t</code> and running a curl for a post request, I get the error:</p>
  <p><code>curl command: curl http://localhost:19999</code>
  <code>Failed connect to localhost:19999; Connection refused</code>.</p>
  <p>I have the expose command in my dockerfile and do not want to expose ports to my host. My service is also up and running inside the container. I also have the property within config set as
  <code>&quot;ExposedPorts&quot;: {&quot;19999/tcp&quot;: {}}</code>
  (obtained through `docker inspect &lt;container id/name&gt;\ Any idea on why this is not working? Using docker for Mac</p>
  <p>I'd post my docker-compose file too but this is being built through maven. I can ensure that I am exposing my port using 19999:19999. Another weird issue is that on disabling my proxies it would run a very light weight command for my custom service and wouldn't run it again returning the same error as above. The issue only occurs on my machine and not others</p>