Closed TanmoySG closed 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
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.
Description