1

I have server with 20/30 sites to hosts and I would like to use Docker containers for scalability, maintenability and security.

After few searches, I found 2 approaches :

  1. one container per application, (with all included such as LAMP),
  2. one container per "service", such as Apache, Mysql... And apps.

Regarding my goal (20/30 sites to hosts, duplicate containers for similar apps...) I would have chosen the 1st one. Being totally beginner, I ask for advice : what's the best?

Thanks for your answers !

Nicolas

4
  • You have one server?
    – dawud
    Jun 24, 2016 at 15:15
  • Yes. I actually have a VPS (9 sites only), and plan to switch on dedicated. Sites I mention are quite small, and 20/30 is a projection. As I will start from scratch I would like to take good decisions from the beginning.
    – nbonniot
    Jun 24, 2016 at 15:18
  • Quite honestly, there's not much scalability or resilience you can provide with just one server. What do you intent to use to manage the containers at that scale?
    – dawud
    Jun 24, 2016 at 15:33
  • Thank you for your remark. Scalability it perhaps unappropriate here, I meant ability to increase/decrease resources per container (cgroups ?). My other points are perhaps more justified, with security (each container is isolated?) and maintenability (ability to create images with optimal production configuration, quick and easy on/off, images updates, images usable on local dev environnment...). Like I said, totally noobs here, feel free to light things you would add/remove/change.
    – nbonniot
    Jun 24, 2016 at 15:38

1 Answer 1

0

The preferred solution in a greenfield is to have one container per service, so an Apache container and a separate Mysql container. Since Apache will spawn and communicate with the app directly in most LAMP stacks, I wouldn't separate these. Place both of these containers inside a docker-compose.yml definition and start them together in a private network (default with docker-compose). This give each pair of containers the ability to refer to each other by dns on the container name, and makes upgrades easier (you can just swap out the db container without rebuilding the web server).

The app, when loaded with a scripting environment like php, will typically be installed as a volume on the Apache container.

2
  • Thank you for your answer. Assuming my understanding is correct, you would install MysqL on a container, and the rest (Apache, PHP and app) in another one, wouldn't you? An repeat/adapt last container for each app hosted on the machine? Could you also provide advice about mail server? Based on the fact I also own also VPS, would it be better to separate physically mail server from dedicated server hosting using the VPS? or provide a container for mail service on dedicated server?
    – nbonniot
    Jun 27, 2016 at 8:08
  • I'd give each Apache/PHP container it's own associated DB container if that makes sense in your environment. Makes it easier to separate each environment from each other, and also upgrade them one at a time. The mail server location is more of an opinion, pros and cons to each.
    – BMitch
    Jun 28, 2016 at 11:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .