how to configure docker to use apache and php in separate containers
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 mysqldocker run --link db php:5.4docker 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?