正在摸索用docker运行LNMP环境,有个问题不是很清楚,
假设有两个分站,
aaa.xxxxxxx.com
bbb.xxxxxxx.com
对应有两个project文件夹,分别是project-a,project-b,
两个文件夹中分别有自己的docker-compose.yml文件,里面分别定义了nginx+php+mysql的一些东西。
问题:
在两个文件夹中分别执行docker-compose up
的时候,nginx+php+mysql是运行了两份,还是一份呢?
如果运行两份,那不是很占空间吗,当有N个分站的时候,那可咋办?
伊谢尔伦2017-04-24 09:13:38
docker-compose.yml
对应一套 Nginx + PHP + MySQL。如果你分别在各自目录中 docker-compose up -d
in a project directory twice, then there are two sets.
Yes, if you divide it into multiple sites like this, it will waste a lot of memory space, especially MySQL, because there are a lot of duplications.
Although Docker is lightweight, it does not mean that it can remove duplicate memory usage and will not help you compress memory space.
What you are doing is absolute isolation, so that there is no intersection between sites. It is good from a security perspective, but this isolation means multiple copies. You need to consider whether such isolation is necessary.
Maybe you need to look at the problem not from the site perspective, but from the service perspective. What you need is 3 services, so a set of docker-compose.yml
runs three services, Nginx, PHP, and MySQL. Then for multi-site needs, just configure nginx and mysql database like a traditional server.