I am groping for a way to run LNMP environment with docker. One problem is not very clear.
Assuming there are two substations,
There are two project folders, Project-A and Project-B respectively.
The two folders have their own docker-compose.yml files, which define nginx+php+mysql respectively.
Execute separately in two folders
docker-compose upAt that time, was nginx+php+mysql running twice or once?
If you run two, isn’t that a lot of space, and when there are n substations, what can you do?
In a project directory
docker-compose.ymlCorresponding to a set of Nginx+PHP+MySQL. If you are in their respective directories
docker-compose up -dTwo times, then this is two sets.
Yes, if you divide multiple stations like this, you will waste a lot of memory space, especially MySQL, because there are a lot of repetitions.
Docker is lightweight, but it doesn’t mean you can eliminate duplicate memory usage and won’t help you compress memory space.
The way you do this is absolute isolation, allowing stations to have no intersection directly, which is very good from a security point of view, but this isolation means multiple copies. You have to consider whether such isolation is necessary.
Perhaps you need to look at the problem not from a site perspective but from a service perspective. What you need is three services, so one set
docker-compose.ymlRun three services, Nginx, PHP, MySQL. Then, for multi-site requirements, just like traditional servers, configure nginx and mysql databases.