Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker containers: services vs full applications

Tags:

docker

I'm having an ongoing debate with myself about how to think about and use Docker containers.

From the literature and examples it seems like a container should really provide a service, or part of a stack. For example a container might run MySQL, or Apache, or redis, or whatever. I can understand why this is nice and clean, and makes sense.

In our scenario, we want to host multiple totally separate web applications (e-commerce stores, wordpress sites, static websites, node.js applications) all on the same server, and we want to use Docker. For me therefore it makes more sense for each container to be totally self-container, with the entire stack in itself e.g. each of my possibly several running wordpress containers would each have their own LAMP installation.

To apply the one-container-one-service model to this scenario seems to be very complicated - each application will have dependencies on other containers in the system which will in turn be depended on by other things. And what if you require multiple versions of a particular service.

Whilst this seems like the way to go, it also seems like it could be very inefficient? I'm not an expert on how LXCs work but even though everything is containerised, there really are all those apache2 workers and mysqlds running on the system, with all their associated overhead - is there going to be performance problems?

Does anyone have any thoughts?

like image 920
Joe Woodhouse Avatar asked Jun 12 '14 18:06

Joe Woodhouse


1 Answers

I would prefer the one container per app approach. If you put every service in a single image/container, you have some advantages:

  • You can easily compose new stacks, use an Apache instead of Nginx.
  • You can reuse components, e.g. I use to deploy the same Logstash image with every application to collect logs.
  • You can use predefined services from the Docker Index (now called Docker Hub). If you need to setup a Memcached service, you can just pull the image.
  • You can control every service, e.g. to stop it or to update it. If you want to update your app, you only need to rebuild a single image and only upload/download a single image.

Since LXC and Docker seems to be very efficient, I wouldn't mind to use multiple containers. This is what Docker was designed for. And I think you will have a reasonable number, lets say <100 containers. So it shouldn't be a problem.

like image 57
Thomas Uhrig Avatar answered Oct 22 '22 17:10

Thomas Uhrig