Discussion:
[Supervisor-users] Supervisor Support for Docker
Michael Ihde
2016-04-27 19:37:55 UTC
Permalink
I love using supervisor for many of my programs. Recently I've also been
using supervisor to launch docker containers (i.e. command=docker
run....). This has generally worked very well except for one particular
issue; I like to use the docker --name option to ensure my containers have
the same name as the supervisor jobs. The downside of this is that there
are a variety of corner cases where docker will not auto-delete the
container even if --rm=true is used. When supervisor goes to start the job
it fails because the name is already taken.

Some workarounds would be:

- Don't use --name and simply let the containers get unique UUIDs.
- Build some form of wrapper script for the docker command
- Change the behavior of docker ;-)

Ultimately I decided that it would be nice if supervisor was
"docker-aware". I wanted to make it as an rpcinterface plugin but wasn't
happy with the result because I wanted to include the necessary docker
information within the [program] section and there did not appear to be a
straightforward way to extend the option parser from a plugin.

The alternative was to extend supervisor itself in a manner similar to how
fastcgi support is included in supervisor. I've made the necessary changes
and submitted a pull request, but I see that the Travis CI build was
failing because I used some deprecated Python syntax. I'll go back and fix
up the code so that it passes all the Travis CI tests...but I wanted to see
if this was thought to be a useful enhancement. If not, are there
alternate approaches that would be better?

~Michael
Aryeh Leib Taurog
2016-04-28 13:41:30 UTC
Permalink
It could be that docker has changed since this last came up on the
list, but my recollection is that supervisord is quite good inside
containers, but not at all suitable for running containers, due to
the fancy footwork docker does with processes.
Post by Michael Ihde
I love using supervisor for many of my programs. Recently I've also been
using supervisor to launch docker containers (i.e. command=docker
run....). This has generally worked very well except for one particular
issue; I like to use the docker --name option to ensure my containers have
the same name as the supervisor jobs. The downside of this is that there
are a variety of corner cases where docker will not auto-delete the
container even if --rm=true is used. When supervisor goes to start the job
it fails because the name is already taken.
- Don't use --name and simply let the containers get unique UUIDs.
- Build some form of wrapper script for the docker command
- Change the behavior of docker ;-)
Ultimately I decided that it would be nice if supervisor was
"docker-aware". I wanted to make it as an rpcinterface plugin but wasn't
happy with the result because I wanted to include the necessary docker
information within the [program] section and there did not appear to be a
straightforward way to extend the option parser from a plugin.
The alternative was to extend supervisor itself in a manner similar to how
fastcgi support is included in supervisor. I've made the necessary changes
and submitted a pull request, but I see that the Travis CI build was
failing because I used some deprecated Python syntax. I'll go back and fix
up the code so that it passes all the Travis CI tests...but I wanted to see
if this was thought to be a useful enhancement. If not, are there
alternate approaches that would be better?
~Michael
_______________________________________________
Supervisor-users mailing list
https://lists.supervisord.org/mailman/listinfo/supervisor-users
Michael Ihde
2016-04-29 13:13:49 UTC
Permalink
I agree that supervisor is great running inside containers, but I'm talking
about having supervisor run containers themselves. I've been having
supervisor run containers for almost 6 months now with no issues; there is
nothing fancy about it and it has benefits over other options.

There are a variety of people that are doing this (or want to do this) as
well:


http://stackoverflow.com/questions/30034813/best-way-to-manage-docker-containers-with-supervisord

http://stackoverflow.com/questions/31074492/launching-multiple-docker-containers-with-supervisor

http://stackoverflow.com/questions/31197724/shutting-down-docker-containers-via-supervisor


There is only one issue (which I described in the original e-mail) that has
to do with a corner case of using named containers. My patches add support
for Docker directly into the supervisor configuration, which fixes this
corner case and helps new users correctly get things working (since there
are various Docker flags which must be set correctly for it to work).

Cheers,
~Michael




On Fri, Apr 29, 2016 at 1:00 PM, <
Re: [Supervisor-users] Supervisor Support for Docker
Continue reading on narkive:
Loading...