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.

  • how to map a local folder as the volume the docker container or image?
  • How can I link files in Dockerfile?
  • Symfony MongoId Class not found error
  • Deploying docker container using marathon
  • Why does deploying on Kubernetes take so long?
  • How to find docker.socket file after change of docker root folder ?
  • How to SSH into running container using docker
  • Why can't apache communicate with php-fpm in separate containers using Docker for Windows?
  • How to send log from Vagrant server to Graylog server
  • Docker create images “Ubuntu 14.04” with Docker file
  • How to set up two Nginx containers as a reverse proxy in an active-passive set up with failover?
  • Error: image orgsync/java8 not found
  • 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.