Go to file
Peter Bourgon 4e6968fe8f First draft 2015-09-25 14:37:17 +02:00
.gitignore First draft 2015-09-25 14:37:17 +02:00
Dockerfile First draft 2015-09-25 14:37:17 +02:00
LICENSE Initial commit 2015-09-25 11:29:49 +02:00
README.md First draft 2015-09-25 14:37:17 +02:00
bar First draft 2015-09-25 14:37:17 +02:00
foo First draft 2015-09-25 14:37:17 +02:00
main.go First draft 2015-09-25 14:37:17 +02:00
run-bar First draft 2015-09-25 14:37:17 +02:00
run-foo First draft 2015-09-25 14:37:17 +02:00

README.md

reap

If you have a Docker container that's a collection of runit-supervised daemons, this process is suitable for use as the ENTRYPOINT.

FROM alpine:latest
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >>/etc/apk/repositories && apk add --update runit && rm -rf /var/cache/apk/*

ADD foo /
RUN mkdir -p /etc/service/foo
ADD run-foo /etc/service/foo/run

ADD bar /
RUN mkdir -p /etc/service/bar
ADD run-bar /etc/service/bar/run

ADD reap /
ENTRYPOINT ["/reap"]

Why not just exec runsvdir?

docker stop issues SIGTERM (or, in a future version of Docker, perhaps another custom signal) but if runsvdir receives a signal, it doesn't wait for its supervised processes to exit before returning. If you don't care about graceful shutdown of your daemons, no problem, you don't need this tool.

Why not wrap runsvdir in a simple shell script?

This works great:

#!/bin/sh

sv_stop() {
	for s in $(ls -d /etc/service/*)
	do
		/sbin/sv stop $s
	done
}

trap "sv_stop; exit" SIGTERM
/sbin/runsvdir /etc/service &
wait

...except it doesn't reap orphaned child processes and is therefore unsuitable for being PID 1.

Why not use my_init from phusion/baseimage-docker?

That works great — if you're willing to add python3 to your Docker images :)

So this is just a stripped-down my_init in Go?

Basically, yes.