title: How to redirect external link in a Docker container to local service
body: <p>I'm still early on my Docker journey and I'm trying to 'Dockerise' an existing UI/API/DB web app where the UI &amp; API/DB are on two different servers. It's gone fairly well so far and my docker-compose fires up services for UI, API &amp; DB (and phpMyAdmin) just fine. I know that those services can communicate inherently using service names as host names due to the default networking method of Docker.</p>
  <p>The UI (an Angular codebase) makes various calls to <a href="https://api.myproject.com" rel="nofollow noreferrer">https://api.myproject.com</a> which works fine in the live sites but isn't ideal in my Docker version as I want it to reach my API service in the container not the API live site.</p>
  <p>I know that I can edit the code on the UI container and replace calls to <a href="https://api.myproject.com" rel="nofollow noreferrer">https://api.myproject.com</a> with calls to 'api' but that's inconvenient and lacks portability if I want to redeploy on different servers (as it is now) in future.</p>
  <p>Is it possible for a container to redirect all POST/GET etc. for a URL to a container service? I thought the <code>--add-host</code> might do something like this but it seems to want an IP address rather than a service name.</p>
  <p>Thanks in advance.</p>
  <p><strong>EDIT [clarification]</strong>
  My issue lies in the UI page (HTML/JS) that the user sees in the browser. When the page is loaded it throws some GET requests to the API URL and that's what I was hoping to redirect to the container API service.</p>