Home » Php » how to configure docker to use apache and php in separate containers

how to configure docker to use apache and php in separate containers

Posted by: admin July 12, 2020 Leave a comment


i need to setup a particular LAMP environment using docker, with :

  • debian squeeze 6.0.10
  • apache 2
  • php 5.6
  • mysql 5.5

having app code hosted on a base image with debian + apache, i wonder if it’s possibile to use a php container instead default php server installed on debian container ( witch is 5.3 ) in the same way i do with mysql container.

here is a small image that better explain what is the idea

is it possibile?



After some researches i think that is impossible, unless you configure php as cgi module, not worth it even for a modular configuration.

you should have system administrator skills to manage it right and however production server never can be configured in the same way, especially the ones used by common hosting provider.

How to&Answers:

For what its worth, I am currently working on something similar which gives you the option to freely choose from different PHP versions (pre-configured via PHP-fpm), as well as different MySQL and Apache/Nginx versions.

They are chosen by simply setting a configuration variable to a specific version and then starting the containers.

You can have a look at the project here:


You might get some ideas about how this is all linked.
Compose file is here: https://github.com/cytopia/devilbox/blob/master/docker-compose.yml


As I understand you want to access your MySQL instance from two php containers.

This is definitely possible.

Your setup would look something like this:

docker run --name db mysql
docker run --link db php:5.4
docker run --link db php:5.6

This will provide you with one mysql container and two php containers with their respective versions.

Does this answer your question?