TanmoySG / wunder-identity-provider

ID Provider for Wunder Platform. Authentication & Authorization Server for all wunder products
3 stars 0 forks source link

[Bug Fix] Fix the Compose File #91

Closed TanmoySG closed 2 years ago

TanmoySG commented 2 years ago

Description

 requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=8080): Max retries exceeded with url: /testapp001/testcontext001 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fe129b60400>: Failed to establish a new connection: [Errno 111] Connection refused'))
wunder-identity-provider_wunderidentityprovider_1 exited with code 1
TanmoySG commented 2 years ago

https://stackoverflow.com/questions/41171115/why-cant-i-curl-one-docker-container-from-another-via-the-host

TanmoySG commented 2 years ago

💡 Learning Point

[Background] I was trying to cURL into a container, monitor from another container alpine. The Setup for monitor was

version: '3.4'

services:
  monitor:
    image: ghcr.io/tanmoysg/logsmith-monitor:latest
    ports:
      - "8080:8080"
    expose:
      - 8080
    volumes:
      - monitorvolume:/usr/src/app/logfiles
    networks:
      - wundernetwork
networks:
  wundernetwork:
    driver: bridge

volumes:
  monitorvolume:

And the alpine container was run using

docker run -i --network wunder-identity-provider_wundernetwork alpine

Both are on same network - wundernetwork

I wasn't able to curl localhost:8080/

Came across this stackoverflow thread

https://stackoverflow.com/questions/41171115/why-cant-i-curl-one-docker-container-from-another-via-the-host

According to this we can use the name of the container as hostname. So from inside the alpine container curl worked with

curl wunder:8080/

[Generalisation] In a docker "swarm" use the name of the container as the hostname for an URL instead of localhost.

[Citation] https://stackoverflow.com/a/41172678/11125890