1

I have an application running locally and I have a docker container running via docker compose:

  swagger:
    image: swaggerapi/swagger-ui:v3.23.5
    ports:
      - "7171:8080"
    networks:
      - dockernet
    expose:
      - 8080
    environment:
      - URL=http://192.168.10.20:8080/actions/v3/api-docs

192.168.10.20 is my localhost.

if I access http://192.168.10.20:8080/actions/v3/api-docs via the browser I see the response but the swagger service can't access it.

How to fix it?

williamcodes
  • 6,317
  • 8
  • 32
  • 55
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710
  • In the ports, 7171 is the host port, what happens if you try - URL=http://192.168.10.20:7171/actions/v3/api-docs? Also, how is 192.168.10.20 your localhost? – james Apr 20 '20 at 12:29
  • For accessing the UI you exposed port `7171` to the host, so you should use `http://192.168.10.20:7171`. Also, I don't see `URL` as an available environment var for the swagger container? The only similar one I see is `BASE_URL`. – J. Scott Elblein Apr 20 '20 at 12:30
  • http://192.168.10.20:7171 doesn't work – gstackoverflow Apr 20 '20 at 12:34
  • Do the answers to [From inside of a Docker container, how do I connect to the localhost of the machine?](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) help you? When you say "it doesn't work", what behavior are you seeing (for example, what's the specific error your application is producing)? – David Maze Apr 20 '20 at 13:12
  • Have you tried to replace `192.168.10.20` with `host.docker.internal`? This did the trick for me on Windows. See [link](https://docs.docker.com/docker-for-windows/networking/) – Xantipus Apr 23 '20 at 11:09

0 Answers0