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.

  • How to send to stdin of a docker-py container?
  • how to activate/passivate docker containers in aws
  • Running a Bash Script from (on Docker Container B) from Docker Container A
  • Setup GitLab CI for Rails with npm
  • Launch Docker containers to handle HTTP requests
  • Dockerhub Create Automated Build step stuck at Creating
  • Below is a diagram of the container interactions.

    Docker container interaction

  • How to configure xvfb default installation on Jenkins startup?
  • Best way to clone private git gem repo using Dockerfile
  • Docker Ubuntu 12.04
  • Simple Docker networking — not sure where to even start
  • can we mention more than one node label in single nodeSelector in kubernetes
  • Docker containers in different directories under one daemon
  • 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.