I want to host multiple independent wordpress sites (4-10) on a rootserver. I want to host them using docker containers. Now the Q: Is it better to run ONE mysqldb running all wordpress schemes for the multiple sites, or is ist better to run one mysql instance per wordpress. Thank you. N.
3 Answers
Following Docker's philosophy of "one application per container" you should have a database container for each WordPress instance. This way each database is isolated from the others. Should anything happen to one database it will not affect the others. Also, if you want to migrate or take down one website you only need to act upon its containers.
The official WordPress image is prepared to link to another container providing a database. Therefore you will have two containers per website: one for the WordPress files and another for the database. For the databases you might use the official MariaDB image.
The traffic for the several WordPress containers might then be distributed by a proxy container such as this one.
-
I do not fully agree with your statement, I can still have "one application per container", one Wordpress instance per container without duplicating all the below stack. It is perfectly fine to have one database service, maybe on a different host, and create on it different schemas for each Wordpress instance. Commented Jan 24, 2021 at 8:14
I saw something that may help you. Click here to see : http://donalfarrell.com/2015/08/11/Docker-Nginx-Multi-Wordpress.html
Basically you need to use reverse proxy to resolve this problem and you can use the 'link' property do sync your web application with specific database container. Nginx container to do reverse proxy, may be a good solution for you.
I hope it helps =)
If you don't have resource problem then create a docker-compose file per WordPress with a MySQL container per WordPress. Apps will be isolated, if not you can have some problems if you use one MySQL db container for all sites