I would like to have a RUnit service to supervise a set of containers launched by docker-compose
tool, here's my the runit script:
In /etc/sv/app/run
#!/bin/bash
exec 2>&1
APP_HOME=/home/myapp
source $APP_HOME/env.sh
exec docker-compose -f $APP_HOME/docker-compose.yml up
Here's what I have then:
sv start app
- launches the docker-compose thing just finesv stop app
- stops docker-compose process itself but for unknown reason it leaves the containers running
Is there any chance to have the stop
command to stop containers as well? I thought that is what docker-compose should do when it gets stopped by RUnit.
I'm not familiar with docker (yet) but I have familiarity with runit.
When you issue
sv stop app
you are actually tellingrunsvdir
to signal therunsv
for your docker launch to tear down the process. If you need something to signal the container to shut down, it won't happen becauserunsv
will haul off and kill any child processes that are attached. You may wish to read up on./finish
scripts, which are tasked with cleaning up things.