Is it possible to have a Supervisord pretask?

I’m currently having Supervisor run some Docker containers for me. This is besides the point, but the thing about Docker is, right now, it doesn’t always clean up after itself. When it doesn’t Supervisord is unable to restart it and eventually goes to FATAL, and I have to manually go in, run a clean-up script, and then supervisorctl reload to get things going again.

Now, the clean-up script I have is idempotent, so what would be really great is if there was a way for me to tell supervisor to always run that script before running Docker. Is there a way to do that? Should I just add my docker run ... command to the end of the script, and have supervisor just run the script? What’s a good solution in this situation?

  • Adding sphinx container docker-compose shows an error
  • Docker IBM SDK-8 Image - Getting thread/memory dump
  • How to debug rails application which is running inside docker container
  • Powershell Install-Package from Nuget
  • FATA[0000] Get http:///var/run/docker.sock/v1.17/version: dial unix /var/run/docker.sock
  • Destination location when using ADD command if <dest> is not provided
  • Starting vncserver using supervisord inside a Linux container
  • Jenkins wrong volume permissions
  • Should Docker Swarm Master be separate physical node?
  • Docker: Connect to container (without exposing ports)
  • Why does `apt install postgresql` not work in a docker container?
  • Installing chef-server in a docker container
  • One Solution collect form web for “Is it possible to have a Supervisord pretask?”

    You could run a script triggered by docker events, similar to the one at this question

    So, something like:

    docker events --filter 'event=start' | while read event
    do
        # run your clean-up here
    done
    
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.