0
  • I have two docker containers A and B that runs on the same user-defined network.
  • Container A has a port published, container B hasnt.

  • I do my requests on container's A published port, but container A needs to do requests on container B.

  • The requests to B inside A are mapped to 0.0.0.0:(container B needed port)/route.

  • These fails.

How could I call B inside A without getting and changing IP based on the network every time?

1
  • 2
    by using the container name as the hostname Dec 20, 2018 at 16:03

1 Answer 1

2

If you have a user-defined network set to bridge, you can access other containers by their container's name which is automatically as hostname for containers inside same network.

So from containerA you could do ping containerB without problems. In your case it would be changing the setting to containerB_name:(container B needed port)/route

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.