Docker Community Forums

Share and learn in the Docker community.

(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: