---
title: "Monitor scheduled jobs in Docker and Compose"
url: "https://cronmissed.com/guides/docker-compose.md"
canonical_url: "https://cronmissed.com/guides/docker-compose"
last_updated: "2026-11-03"
type: "how-to"
summary: "Docker has no scheduler, and a restart policy turns a finished job into a loop. Run jobs from the host and ping from the wrapper script."
related: ["https://cronmissed.com/guides.md", "https://cronmissed.com/snippets/docker.md", "https://cronmissed.com/learn/docker-healthcheck.md", "https://cronmissed.com/guides/linux-crontab.md", "https://cronmissed.com/learn/overlapping-cron-runs.md", "https://cronmissed.com/guides/systemd-timers.md"]
---

# Monitor scheduled jobs in Docker and Compose

> **For AI agents:** the complete index of CronMissed pages is [llms.txt](https://cronmissed.com/llms.txt). Every page is also served as markdown at its URL plus .md.

Docker has no scheduler, and a restart policy turns a finished job into a loop. Run jobs from the host and ping from the wrapper script.

Docker runs containers; it does not schedule them. Scheduled work in a container comes from cron on the host, a cron inside the container, or an app-level scheduler, and a restart policy can quietly turn a finished job into an endless loop. Ping from the wrapper that runs the job.

## How can a scheduled job fail silently on Docker and Compose?

- The default restart policy is "no". With "always" or "unless-stopped" a job container that exits is started again straight away, so a one-shot job runs over and over instead of once on schedule.
- "on-failure" restarts a container only when it exits with a non-zero code, and does not restart it when the Docker daemon restarts.
- A Compose healthcheck decides whether a service container is healthy, not whether a scheduled job ran. A healthy container can sit idle for days with a stuck scheduler inside.
- A cron daemon inside a container is easy to start without anything reading its mail or logs, so its failures go nowhere.

## What are the limits of Docker and Compose?

| Limit | What the documentation says |
| --- | --- |
| Restart policies | no (default), on-failure[:max-retries], always, unless-stopped. |
| always | Restarts the container whenever it stops; a manually stopped container is restarted only when the daemon restarts or the container is restarted by hand. |
| unless-stopped | Like always, except that a container stopped by hand stays stopped, even after the daemon restarts. |
| Compose healthcheck | Declares a command run to decide whether the service containers are healthy, with the same defaults as the HEALTHCHECK instruction. |

## How do you add a CronMissed ping to Docker and Compose?

The most reliable pattern is cron or a systemd timer on the host, running a one-off container, with the ping in the wrapper around `docker compose run`. The container stays free of the ping URL and of any scheduler.

```
#!/bin/sh
# /usr/local/bin/run-report.sh, started by cron: 20 4 * * * /usr/local/bin/run-report.sh
PING_URL="https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10"
curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "$PING_URL/start"
output=$(docker compose -f /srv/app/compose.yaml run --rm report 2>&1)
status=$?
printf '%s\n' "$output" | tail -c 100000 | curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null --data-binary @- "$PING_URL/$status"
exit $status
```

For a long-running worker that loops on its own schedule, ping from the loop after each pass.

```
services:
  worker:
    image: example/worker:latest
    restart: unless-stopped
    environment:
      PING_URL: https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10
    command: >
      sh -c 'while true; do /app/run-once && curl -fsS --max-time 10 --retry 3 -o /dev/null "$$PING_URL"; sleep 300; done'
```

## Which check settings fit Docker and Compose?

For the host pattern, create a cron check that matches the host's crontab. For the looping worker, use a simple check with a period slightly longer than the loop (a 300 second loop gets a 330 second period) and a grace of a few minutes. A container that is stuck, rather than stopped, is the case this catches that a restart policy cannot.

## How do you confirm the check works?

1. Run the wrapper script by hand and check the start and success pings arrive.
2. Stop the worker container with docker compose stop worker and confirm the check goes late and then down.
3. Make run-once fail and confirm the loop does not ping, so the check goes down after the grace.

## Questions

### Should I use the Compose healthcheck to send pings?

It works for a long-running service, since the healthcheck command runs on an interval, but it reports that the check command ran, not that your job finished. Ping from the job itself when you can.

### Can I run cron inside the container?

You can, but then the container needs the cron daemon, a way to log its output, and a restart policy that does not fight it. Host cron or a systemd timer starting a one-off container keeps the pieces simpler.

## Sources

- [Docker Docs: start containers automatically](https://docs.docker.com/engine/containers/start-containers-automatically/), read 22 October 2026
- [Docker Docs: Compose services reference](https://docs.docker.com/reference/compose-file/services/), read 22 October 2026

## Related pages

- [Docker](https://cronmissed.com/snippets/docker.md)
- [Docker HEALTHCHECK](https://cronmissed.com/learn/docker-healthcheck.md)
- [Linux crontab](https://cronmissed.com/guides/linux-crontab.md)
- [Overlapping cron runs](https://cronmissed.com/learn/overlapping-cron-runs.md)
- [systemd timers](https://cronmissed.com/guides/systemd-timers.md)

## Related

- [Monitor cron jobs on every platform: 24 guides](https://cronmissed.com/guides.md)
- [Ping CronMissed from a Docker container](https://cronmissed.com/snippets/docker.md)
- [Docker HEALTHCHECK guide and job pings](https://cronmissed.com/learn/docker-healthcheck.md)
- [Monitor Linux crontab jobs with curl](https://cronmissed.com/guides/linux-crontab.md)
- [How to stop overlapping cron job runs](https://cronmissed.com/learn/overlapping-cron-runs.md)
- [Monitor systemd timers with a ping](https://cronmissed.com/guides/systemd-timers.md)
