• 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 B needed port)/route.

  • These fails.

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

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

1 Answer 1


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 you have read our privacy policy.

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