How does network communication between 2 Docker Containers work?

I have two Docker Containers. How can can Container A communicate with Container B over TCP?

In my scenario: Container A runs Apache. Container B runs PHP-FPM. Apache needs to talk to PHP-FPM.

  • What is a sparse block device at /dev/xvdf
  • Tutum HAProxy Docker Virtual Host forward to entry point path
  • monax command not found on windows
  • Docker: Strider CD dashboard assets broken on installation
  • How to change owner of Docker for Windows
  • What is the location of the docker image files on OS/X?
  • Docker Container Based on Non Existing Image?
  • docker0 interface missing on osx
  • What happens when the docker host restarts?
  • Docker error at higher core counts on a multi core machine
  • Docker Build: mkdir creates folders, but they disappear in runtime
  • Docker multi-container logging cap
  • One Solution collect form web for “How does network communication between 2 Docker Containers work?”

    I just answered that this morning 🙂

    Link to the answer (it talks about php-fpm and nginx, but the concept is the same for apache of course): https://stackoverflow.com/a/19997381/227887

    Long story short, you want to use container linking, a new feature as of 0.6.5 that permits to expose a port from a container to another.

    See also the official docker documentation : http://docs.docker.io/en/latest/examples/linking_into_redis/

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