Using dumb-init to lazy start a container (Question/Feature Request)
marcosdiez opened this issue · 3 comments
Let's assume my application needs many (not so) micro services to run, each of them in a different container.
For developers to work on this application, they need to load all the containers at the same time, which uses a significant amount of RAM. Some developers like fancy thin under powered laptops and Java containers don't make their lives easy. Even though not all developers need all the containers at the same time, having "application profiles" which loads some of the containers for some expected usage pattern opens a new dimension of problems.
How about if we added an option for dumb-init
to lazy run the container CMD
after an event. For example, it could bind to port 8080
and wait idle. After the first request to port 8080, it could stop listening to it and actually run the normal CMD
. Something like dump-init -lazy-wait-for-port 8080
That would guarantee all my developers would run the whole application, but launching some/each service on demand, which would means much less RAM would be used.
All to the price of the first tcp connection being broken.
We could also just wait for the application to launch and redirect the traffic. It would be harder to implement, would cause more latency but then the first connection would not break.
Does that make sense ?
I am looking for a second opinion here. I could implement it myself.
I think we'd have to rename the project to "smart init" :P
Sounds like you could easily write your own sin which runs under dumb-init and does the same thing you're describing. Maybe something like:
dumb-init -- lazy-start 8080 -- java -Xmx4G ...
Yes. Even easier. I would have to add two binaries to my containers but make sense to keep it separated. I'll think about it ! Thanks for the suggestion.
Consider that there's other work in this area that might be applicable or inspire a cleaner solution, see http://blog.developer.atlassian.com/docker-systemd-socket-activation/ for example. What you are looking for is a socket activation proxy.