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.

  • Docker Hub API v2 token authentication issue
  • docker compose file not working: replicas Additional property replicas is not allowed
  • How to execute program in linked docker containers?
  • Upgrade jdk version of Tomcat docker container to 1.8
  • docker4mac shared folder speed too slow
  • Deploying a Sails.js app to dokku-alt? Buildpack error
  • Is it possible for a the host to authenticate to a KDC running on a Docker container?
  • OrientDB “ Error on moving existent database”
  • Docker Swarms and Stacks: What's the difference?
  • Docker commands fails (in Windows)
  • Docker pull error: no space left on device
  • Build Docker image for ARM architecture on Intel machine (Mac)
  • 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):

    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 :

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