Saturday, June 27, 2015

Automatically Remove Long-Running Docker Containers

The following can be used in cron or run with & at the end of the command:


I found this didn't work: http://www.ahtik.com/blog/removing-detached-docker-containers-automatically/

Tuesday, June 2, 2015

Docker Run In Crontab

"0 5 * * 1 docker run --rm --name=mycontainer ubuntu:13.10 /opt/bin/job"
The above command is an example of how "docker run" would be used in crontab to run once every week at 5am.

  • --rm will delete the container once the job is finished running
  • --name will name the container and prevent duplicate jobs from running
  • You don't need to use "&" at the end, because crons already run in the background.