title: Docker-compose swagger-ui setup which doesn't depend on a particular URL
body: <p>I want to add swagger-ui to my docker-compose setup. I'm using postgres and <a href="http://postgrest.org/en/v5.1/" rel="nofollow noreferrer">postgrest</a>. My setup looks roughly like:</p>
  
  <pre><code>version: '3'
  services:
  
    postgrest:
      image: postgrest/postgrest
      ports:
        - 3000:3000
      links:
        - postgres         
  
    postgres:
      image: postgres
      ports:
        - 5432:5432
      volumes:
        - "./pgdata:/var/lib/postgresql/data"
  
    swagger:
      image: swaggerapi/swagger-ui
      expose:
        - 8080
      ports:
        - 8080:8080
      links:
        - postgrest:postgrest
      environment:
        API_URL: http://localhost:3000
  </code></pre>
  
  <p>This shows me the proper API docs UI when I'm testing locally. When I deploy, <a href="http://localhost:3000" rel="nofollow noreferrer">http://localhost:3000</a> isn't serving an OpenAPI definition anymore, and this breaks. I can change API_URL to the remote URL, but then it won't update locally if I'm testing some changes, and that generally seems to defeat the point anyway. </p>
  
  <p>Is there a way to point swagger at "the postgrest running in the same docker compose setup"? Something like:</p>
  
  <pre><code>  swagger:
      ...
      links:
        - postgrest:postgrest
      environment:
        API_URL: http://postgrest:3000
  </code></pre>
  
  <p>Sometimes docker compose can do magic like this, e.g. in nginx. </p>
  
  <p>Thanks in advance! </p>