Docker does some management of dismounted containers: if the system shuts down, then when the Docker daemon starts, it also restarts all containers that started when the system shutdown. But if the container exits by itself or the kernel (or the user) kills the container during its launch, the Docker daemon will not restart it. In cases where you want to restart, the process manager makes sense.
I do not know runit , so I can not give a specific configuration guide. But you should probably get the process manager to interact with the docker ps | grep container_id daemon and check if the given container identifier works ( docker ps | grep container_id or its equivalent, or use the Docker Remote API directly). If the container is stopped, use Docker to restart it ( docker run container_id ) instead of starting a new container. Or, if you want a new container every time, start with docker run -rm to automatically clear it when it exits or stops.
If you do not want your process manager to poll the docker, you can instead run something that is watching docker events .
You can get container_id when you run the container as the return value to start the daemon, or you can ask Docker to write it to a file ( docker run -cidfile myfilename , like a PID file)
I hope this helps or helps another runit guru offer more detailed tips.
source share