Putting a cron job in a Docker container looks like a five-minute task. Install cron, copy a crontab, start the daemon. Then the job silently doesn't run, or runs without its environment, or runs at the wrong hour, and there's no output anywhere.
Here are the questions that come up most, with direct answers.
1. Should I run cron inside a container at all?
Sometimes. The container philosophy is "one process per container", and cron is a long-running daemon that spawns other processes, which fits awkwardly. Common alternatives:
Host cron calling docker run or docker exec .
Your orchestrator's scheduler : Kubernetes CronJobs, ECS scheduled tasks, Nomad periodic jobs, a PaaS scheduler.
A container-friendly scheduler such as supercronic (a crontab-compatible runner designed for containers) or ofelia (a scheduler for Docker that runs jobs in other containers).
That said, a small "cron container" running alongside your app is a perfectly reasonable choice for a single server with Docker Compose.…