Do we end up with multiple Apache/PHP installations when using Docker?

I am trying to understand Docker. The idea is that we can create a complete environment and have it run on any machine. But in my mind there is a problem.

Imagine that I create a Apache/PHP/MySQL application where Apache/PHP is on 1) one container and MySQL is 2) another container. Then my friend says - “Hey mate, I just created this really cool Apache/PHP/PostgreSQL application, can I run it on your server?”. But he also has a Apache/PHP (different configuration) container and a PostgreSQL container. He DID NOT KNOW that there is already a Apache/PHP container running on the server. That means we will have 2 Apache and PHP installations running on the server.

If we were not using Docker we could use the same Apache and PHP. Except we would need to install some Postgres extensions. Is my understanding correct? Is this how it is done?

Yes, that’s the idea, to have a different container for every application, so that they are isolated from each other and you can modify, update, restart them individually. If you want to reduce the overall size of the system it is important to build them in the same way, or maybe you can create a base image that you can use in all of them.

1 Like