Reputation: 561
I have 2 docker containers(container name : A & B) on 1 host & they are connected to same user-defined bridge(test-bridge).
Target state/Trying to achieve:
To be able to call container B from container A via hostname only & not hostname:port.
Current State:
I am able to call API's hosted inside container B via url http://{{containerName:portNumber} i.e. http://B:6000 from container A.
I want to get rid of the port number because IMO being connected on the same network along-with the container name should be sufficient enough to resolve the request to target container.
Is there a way for inter-container communication via this approach
UPDATE
Still looking for a solution as the package that I am working on would be a core utility(at-least 3 containers), this would be deployed with other docker apps. The port number 80 would only help 1 container only but to call other utilities the caller would need to attach port number that I can't expose as it is an infra/network level information.
Upvotes: 0
Views: 562
Reputation: 11337
You can use HTTP default port (80) and then you won't have to specify it.
Change your app B to listen on port 80 - then you'll be able to call http://B
without adding port number.
Upvotes: 1