Docker, CentOS7, and Cron Jobs

For several of our in-house bioinformatics pipelines, we have long-term, recurring jobs that need to be executed. Since we have been moving many of our processing components to a container/microservice model using Docker, we wanted to generate a Docker container that could execute other containers with a recurring cron task. Since neither cron or systemctl are installed in the CentOS base image, this requires a few minor steps in the initial Dockerfile. In terms of launching new containers from within a container, two options exist. Docker-in-Docker, while an option, has several potential limitations and configuration issues. For our implementation, it was easier to take the second approach, which includes the local host’s docker socket as a mounted volume.

First, to set up cron in Docker with CentOS7, include the following in your Dockerfile:

To let your Docker container launch additional containers:


Share This Story:

Leave a Reply