Docker-alpine: Running cron

Created on 24 Dec 2015  路  4Comments  路  Source: gliderlabs/docker-alpine

I am building an image which needs to run a shell script approximately daily. The exact time of execution isn't critical, nor is critical whether it executes at all. I've searched in the documentation but haven't found anything relevant. Could someone provide me with a simple example of how to use cron (or anything similar) with this image?

question

Most helpful comment

BusyBox actually has a simple crond built right in and it can run in the foreground. Here is a trivial example: https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7

All 4 comments

BusyBox actually has a simple crond built right in and it can run in the foreground. Here is a trivial example: https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7

You can have a look at https://github.com/just-containers/base-alpine which has a s6 init system and is able of running multiple services in one container.

Have a look at my repo as an example, it has a cron and syslog running.
https://github.com/shomodj/docker-alpine-s6/tree/master/base

Just note that logs from those services are not directed to docker logs, they are stored in /var/log/syslog

@andyshinn crond works flawlessly. It is exactly what I am looking for, thank you.

thanks @andyshinn for the elegant solution

Was this page helpful?
0 / 5 - 0 ratings