I have an existing service, which I'm not able to modify directly—let's say it's closed source, or too complex to edit, or autoupdates and therefore is not a good target for direct modifications.
I would like to run this cleanly in a Docker container, so I need a single foreground process which should live and die with the service, i.e. starting the process should start the service and when the service terminates (e.g. crashes), the root process should terminate as well, so that the Docker container terminates.
Is there a good pattern or existing tool to do this? Ideally, it would redirect the service's stdout/stderr to its own stdout/stderr.
The service has a regular init script and is started via /etc/init.d/myservice start.
What I've seen quite often is the container starting the service and then using tail -n0 -F on some core log file. That works for giving the container some kind of stdout, but if the service ever crashes, the container just goes silent, keeps running and never outputs anything again. There must be a better way, no?
One example for thinking about this could be svnserve. It actually has the --daemon --foreground option which is officially just for debugging, but works. But what if that didn't exist?