title: how to access the url outside the docker container
body: <p>I have a web frontend and web api app and both has docker support and here is the docker compose file for it.</p>
  <pre><code>version: '3.4'
  
  services:
  webfrontend:
  image: ${DOCKER_REGISTRY-}webfrontend
  build:
    context: .
    dockerfile: WebFrontEnd/Dockerfile
  
  mywebapi:
  image: ${DOCKER_REGISTRY-}mywebapi
  build:
    context: .
    dockerfile: MyWebAPI/Dockerfile
  </code></pre>
  <p>Since both application shares same network, so internally DNS resolves and I am able to access web api from frontend app like below,</p>
  <pre><code> using (var client = new System.Net.Http.HttpClient())
          {
              // Call *mywebapi*, and display its response in the page
              var request = new System.Net.Http.HttpRequestMessage();
              request.RequestUri = new Uri(&quot;http://mywebapi/WeatherForecast&quot;);
              var response = await client.SendAsync(request);
              
          }
  </code></pre>
  <p>Here the web api url <code>http://mywebapi/WeatherForecast</code> ONLY accessible to the frontend app within code (internally) but when I am trying to browse this url over browser or postman, it's failing.</p>
  <ul>
  <li>What is the reason for it ? (browser or postman not in container network?)</li>
  <li>how we can access it outside the container? Do I need to use IP and port or DNS can also I can use?</li>
  <li>can I access same <code>http://mywebapi/WeatherForecast</code> outside?</li>
  </ul>