In this example we are going to create three containers (Apache, MySQL, PHP-FPM) for a web application.


  1. Requests goes to Apache container.

  2. Apache container calls PHP-FPM container.

  3. PHP-FPM container calls MySQL container.

  4. Response is returned to Apache container.

  5. Page is served by Apache container.


  • Web application is stored in host OS so that we can work with it.

  • Apache, PHP-FPM and MySQL logs are shared in host OS so that we can inspect them.

  • MySQL database is stored in host OS so that we can connect to it.

  • A dedicated network is defined and specific IP addresses are assigned to the each containers.

The most important point here is that, when we remove containers we won’t lose any data such as application files, logs and database because they are not stored in containers.

#docker #apache #mysql

Creating Apache, MySQL & PHP-FPM containers for a web application with Docker compose
7.05 GEEK