Monitor Cron Jobs in Docker Compose Services
DevOps & CI/CDThe Problem
Docker Compose services running background cron work can silently fail if the container restarts, runs out of memory, or the entrypoint script has errors.
The Solution
Run cron as a dedicated Compose service and add CronRabbit monitoring. The dead man's switch catches both job failures and container crashes.
Dedicated Cron Service
Create a separate service in docker-compose.yml for cron jobs. This keeps your web/API services independent from scheduled tasks.
Code Examples
Docker Compose cron service
Bash# docker-compose.yml
services:
cron:
build: .
command: cron -f
environment:
- CRONRABBIT_PING=https://ping.cronrabbit.com/your-id
volumes:
- ./crontab:/etc/cron.d/myapp