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?
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
Most helpful comment
BusyBox actually has a simple
crondbuilt right in and it can run in the foreground. Here is a trivial example: https://gist.github.com/andyshinn/3ae01fa13cb64c9d36e7