0

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?

Eli
  • 36,793
  • 40
  • 144
  • 207

1 Answers1

0

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
Community
  • 1
  • 1
Bryan
  • 11,398
  • 3
  • 53
  • 78
  • Hi, is it possible to get the name of the container during the start event ? – user1513388 Mar 08 '16 at 23:27
  • @user1513388 indirectly - you get the unique ID (a long hex number) and can then call the Docker API (or `docker inspect`) to get any other info. – Bryan Mar 09 '16 at 20:21