I guess that it depends of the task executed by the cron. Why would you want your cron to be executed in a container if it can be run on the Docker host?
If the cron script needs to be executed in a container, you can pass the cron script's command to the container and execute the container in the crontab of the Docker host.
E.g. in /etc/cron.d/my-docker-cron on the Docker host:
@midnight root docker run --rm mycontainerimage my-cron-task
I have a video management service. This service is used to upload and manage videos.
I need a cron job which runs and converts these videos into a standard format.
I wanted to know the best practice for this. I will go ahead with your suggestion. Thanks @deviantony .
Anthony Lapenna
Open-source enthusiast
I guess that it depends of the task executed by the cron. Why would you want your cron to be executed in a container if it can be run on the Docker host?
If the cron script needs to be executed in a container, you can pass the cron script's command to the container and execute the container in the crontab of the Docker host.
E.g. in
/etc/cron.d/my-docker-cronon the Docker host:@midnight root docker run --rm mycontainerimage my-cron-task