Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

Thanks!

Update

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.

like image 643
jkkso Avatar asked Oct 16 '15 10:10

jkkso


2 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:

  • http://devilbox.org
  • https://github.com/cytopia/devilbox

devilbox

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

like image 76
cytopia Avatar answered Oct 19 '22 19:10

cytopia


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?

like image 1
michaelbahr Avatar answered Oct 19 '22 20:10

michaelbahr