Hi Till,
In Singularity’s current state we do not have good support for daemon’s within the container. This means that, like you observed, the container does not exit gracefully when you have started daemon(s) within the container. However, I’m working on developing daemon support for Singularity and there is currently a working prototype.
Simply pull that branch and build it, and then proceed as follows with your container:
> singularity start [container.img]
> singularity run [container.img]
The singularity start command will open an “init” process within a PID namespace. The subsequent singularity run command will run your provided %runscript inside the container started by the start command. Please note, there is no stop functionality right now (still a prototype!), so you need to manually kill the init process to kill the container.
> ps aux | grep sinit
Using that command you can get the PID of the sinit process running.
> kill -n 9 [PID]
After you have the PID, sending a SIGKILL to the sinit process with that command will kill the sinit process. Then, your daemons will exit gracefully.
Please let me know if this works for you.
Thanks,
Michael