(solved)A container cant access another container via name or IP although in same network

Hey guys,

I am struggling with this issue for hours and can’t figure it out.

So I have two containers (say named as container-A and container-B) in the same bridge network in the same host.

Then in container-A (by docker exec -it container-A bash), run:

curl container-B

it returns me:

curl: (7) Failed to connect to container-B port 80: No route to host.

Why is that? it seems the containers in the same network cannot communicate with each other.


For more info:

if I run curl container-B-IP in the docker host, then it can return me something I want.

Solved by running only the first command only in this post:

Hello @laventy,
This has already been well expalined in below post!
Basically it’s because of firewall restricting your route communications.
i would highly recommend you to go through below post,

Hi @laventy,

This solution adds more security risks on your docker!
Better to configure only the networks that are created by docker as explained in the below post,