Trozdol February 2016

Do I build a Docker Image for this or do I Need to use Docker Compose?

I'm trying to get into Docker and using a current project as a learning exercise. It's a fairly basic application that uses Centos 7, Node and MySQL.

My first thought was pull a CentOS 7 image and the images for the others mentioned above.

When I tested out a Node image I realized I might not need a Centos Image but I do need MySQL... Not what the recommended way to combine images for this or even if it is the right route for this project.

Should I start with an OS image and install all the dependencies/services I would need like on any other server or do I run the images together with Docker Compose or something like that?

I tried looking at building WordPress images to see what they were doing but most tutorials just reference a prebuilt image.

I'm sure I could hack something together but I wanted to go the preferred route.

My hope was that I could specify all of these things in a Dockerfile so I could share it easily.

Any direction on this is appreciated. Thanks!

Answers


TimWolla February 2016

Quoting from the official best practices:

Run only one process per container

In almost all cases, you should only run a single process in a single container. Decoupling applications into multiple containers makes it much easier to scale horizontally and reuse containers. If that service depends on another service, make use of container linking.

If you want to run more than one process in a container you will need some kind of supervisor or init system and you will lose some of the features docker provides (logging, automated restarting).

All in all it is more hassle than running a container per process. And the latter is slightly secure as well, as the processes cannot attack other processes that easily.


So in your concrete case you would run one mysql container and one node container (possibly based on node:onbuild) and link mysql to node to let node talk to mysql.

Post Status

Asked in February 2016
Viewed 2,860 times
Voted 7
Answered 1 times

Search




Leave an answer