Unable to communicate between docker containers

We are running two docker containers with network as host for each container, We are able to communicate to container from outside world, but we are not able to communicate between the containers.

Is there a way to configure docker network so that containers can communication among themselves as well as outside world.

  • Can not find docker container
  • Sharing directories in a Docker container both with a Dockerfile and after the container is running
  • Why docker uses port numbers from 32768-65535?
  • How to use the docker connection-plugin of ansible?
  • How to log PHP errors in an AWS Elastic Beanstalk Docker container
  • Best practice for redirecting between docker containers
  • Making a variable available between containers?
  • Is there any way, from inside a Java program, to detect if its running in a Docker?
  • Package manager on the Docker Machine default VM?
  • Can't access publicly exposed Docker container port from external machine, only from localhost?
  • Docker running on Centos7 with a Windows 7 container
  • docker-compose env_file available in script but not directy in run command
  • 2 Solutions collect form web for “Unable to communicate between docker containers”

    When you configure a docker container to use “host” networking, you completely remove the docker networking stack, including the container to container networking and built in dns discovery. Everything you see in the container’s network is identical to what you see on the host. So another container listening on localhost is visible on 127.0.0.1 from the host and from other containers with host networking.

    This is not the recommended way to run docker containers in most scenarios. You typically create a docker network for a group of containers, start those containers on that docker network, and then refer to the other containers by their container name.

    Found a solution to my question, I am able to communicate between containers using docker0 network (default network), and to map select ports of container to outside world I am using -p mapping to map from container port to host port.

    as @BMitch suggested a separate network to connect only the containers that need inter container comm is better than using docker0 as all containers without any explicit network configuration connect to docker0.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.