The use and understanding of docker is a bit confusing now, and I would like to ask everyone for advice.
For example:
I currently have a Linux system with 8G of memory.
I need to run two environments on this system: alpha and beta environments.
Alpha and beta environments both use their own nginx and mysql.
My current understanding is that there are two options:
plan 1:
创建两个 container:container_alpha,container_beta。
在两个container_alpha和container_beta和里面都安装好mysql和nginx
Scenario 2:
创建四个 container,在四个container里面都**只**安装
alpha_mysql
alpha_nginx
beta_mysql
beta_nginx
For option one, configuration, use and management will be much easier and clearer.
For option 2, each container only corresponds to one service. I don’t know if this is more in line with the principles of docker.
Or maybe my understanding of docker is not correct yet, so what is the correct way to use docker?
阿神2017-05-16 13:19:50
It depends on what you consider a service, or a "managed unit".
If db+nginx+php is always one-to-one and bound to each other, I think it is okay to treat these as a service.
If the database has master-slave, separation of reading and writing, etc., it will be more convenient to count a mysql as a service.
In addition, option 2 is more friendly to expansion. You don’t need to disassemble the image when you want to change it. You only need to change docker-compose or other configurations.