Docker communication between apps in separate containers

I have been looking everywhere for this answer. To me it seems like an obvious question, however, the answer has eluded me.

My current setup is, I have redis, mongodb and two api servers on the same bridge network. The first server serves as a gateway api that does all the auth, and exposes certain api calls. The backend api is the one that handles all the db interactions and data munging. If I hit the backend (inner) api alone, I am able to see the contents (this api would not be exposed in real production environment). However, if I make the same request from within the gateway api, I am not able to hit the backend (inner) api that is also part of the bridged network I created.

  • Access Wildfly-Docker-Container from Apache-Docker-Container
  • Docker cloud node BYON is unreachable
  • Docker redsocks proxy behind HTTP proxy with no internet DNS
  • Config separate container to different host on Rancher platform
  • jenkins docker plugin job “Permission denied” error
  • Tuleap-Docker : Make autoload-docker return error
  • Below is a diagram of the container interactions.

    Docker container interaction

  • Docker java pass startup param to jar
  • Create base docker centos image with python 2.7.8
  • How docker treats fsync on guest filesystem? Is it possible to lost data during host system crash?
  • Where to keep dependencies (large files or directory structures) for use with Docker/Docker-Compose?
  • Searching a Docker Image for a particular file
  • can not use rabbitmq config in docker build OS X
  • One Solution collect form web for “Docker communication between apps in separate containers”

    I still use legacy linking, but I’m a little bit familiar with this. I think the problem is that you are trying to hit “localhost” from inside your gateway container. The inner API container cannot be resolved as “localhost” inside of the gateway API container. You are able to hit “localhost:8099” from the host machine or externally because of the port mapping, but none of your other containers will be able to resolve that address/port because they ‘think’ it’s a remote machine.

    Here’s a way to test what I’m thinking. In your host’s shell, run the bridge inspect command shown here. Copy the IP address from Containers.<inner-api-hash>.IPV4. Then open a shell in the gateway container with docker exec -it <gateway-id> /bin/bash and then use curl or wget to see if you can hit that IP address you copied.

    If my thinking is correct, you will see that you must use your inner-API node’s Docker assigned IP address from the other containers. Amongst other options, you can start containers with a static IP address as shown here.

    This is starting to escape the scope of my knowledge, but you can also configure a container DNS. Configure container DNS.

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