Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker - one process per container?

Tags:

docker

I sometimes use Docker for my development work. When I do, I usually work on an out-of-the-box LAMP image from tutum.

My question is: Doesn't it defeat the purpose to work with Docker if it runs multiple processes in one container? (like the container started off Tutum's LAMP image) Isn't the whole idea of Docker to separate each process into a separate container?

like image 731
luqo33 Avatar asked Feb 10 '23 06:02

luqo33


2 Answers

While it is generally a good rule of thumb to separate processes into separate containers, that's not the main benefit/purpose of docker. The benefit of docker is immutability. And if throwing two processes into a single container makes for cleaner logic then go for it. Though in this case, I would definitely consider at least stripping out the DB into its own container, and talk to it through a docker link. The database shouldn't have to go down every time you rebuild your image.

like image 189
Sean King Avatar answered Feb 13 '23 03:02

Sean King


Generally sometimes it is neccessary or more useful to use one container for more than one process like in this situation.

Such situation happens when processes are used together to fulfill its task. I can imagine for example situation when somebody want to add logging to the web application by using ELK (Elasticsearch, Logstash, Kibana). Those things run together and can have supervisor for monitoring processes inside one container.

But for most cases it is better to use one process per container. What is more docker command should start process itself, for example running java aplication by

/usr/bin/java -jar application.jar

apart from running external script:

./launchApplication.sh

See discussion on http://www.reddit.com/r/docker/comments/2t1lzp/docker_and_the_pid_1_zombie_reaping_problem/ where the problem is concerned.

like image 43
wsl Avatar answered Feb 13 '23 04:02

wsl