---
title: "Ping CronMissed from a Docker container"
url: "https://cronmissed.com/snippets/docker.md"
canonical_url: "https://cronmissed.com/snippets/docker"
last_updated: "2026-11-03"
type: "how-to"
summary: "A Docker entrypoint that wraps any command with CronMissed start and exit-status pings, for jobs run with docker run or Compose."
related: ["https://cronmissed.com/snippets.md", "https://cronmissed.com/guides/docker-compose.md", "https://cronmissed.com/learn/docker-healthcheck.md", "https://cronmissed.com/snippets/shell.md", "https://cronmissed.com/guides/kubernetes-cronjob.md", "https://cronmissed.com/learn/overlapping-cron-runs.md"]
---

# Ping CronMissed from a Docker container

> **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.

A Docker entrypoint that wraps any command with CronMissed start and exit-status pings, for jobs run with docker run or Compose.

Put the ping in the image's entrypoint and every command you pass to it is reported: the start, the exit status and the end of the output. The container needs curl and the ping URL as an environment variable, and nothing else changes.

## What should a container job send?

- A request to `/start` before the work, so CronMissed can time the run and notice a job that never finishes.
- A request to the plain URL when the work succeeded, or to `/fail` when it did not. `/<exit status>` works too: 0 is a success and any other number is a failure.
- The end of the output in the request body, up to 100,000 bytes, so the alert shows the error without a trip to the server.

## What are the files?

```
FROM alpine:3.20
RUN apk add --no-cache curl
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
```

```
#!/bin/sh
# Usage: docker run --env CRONMISSED_PING_URL=... image command args...
: "${CRONMISSED_PING_URL:?set CRONMISSED_PING_URL}"
ping() { curl -fsS --max-time 10 --retry 5 --retry-connrefused -o /dev/null "$@" || true; }

ping "$CRONMISSED_PING_URL/start"
output=$("$@" 2>&1)
status=$?
printf '%s\n' "$output" | tail -c 100000 | ping --data-binary @- "$CRONMISSED_PING_URL/$status"
printf '%s\n' "$output"
exit "$status"
```

Keep the ping URL in an environment variable or a secret store, never in a public repository: the URL is the check's only credential.

## How do I run it on a schedule?

```crontab
# host crontab
15 3 * * * docker run --rm --env CRONMISSED_PING_URL="https://ping.cronmissed.com/5f0c1b2e-7a3d-4c8e-9b61-2d4f8a7e3c10" example/report /app/nightly-report
```

The scheduler stays on the host, as in the [Docker and Compose guide](https://cronmissed.com/guides/docker-compose.md), and the container does one job and exits. Do not give such a container a restart policy of always, or it will run again as soon as it ends.

## Questions

### Can I use this with a base image that has no curl?

Install curl in the image, or use wget with --post-file if the image has it. Busybox wget supports HTTPS in most current images.

### Why echo the output again at the end?

The wrapper captured the output to send its tail. Printing it again keeps it in docker logs for whoever looks later.

## Sources

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

## Related pages

- [Docker and Compose](https://cronmissed.com/guides/docker-compose.md)
- [Docker HEALTHCHECK](https://cronmissed.com/learn/docker-healthcheck.md)
- [Shell and curl](https://cronmissed.com/snippets/shell.md)
- [Kubernetes CronJobs](https://cronmissed.com/guides/kubernetes-cronjob.md)
- [Overlapping cron runs](https://cronmissed.com/learn/overlapping-cron-runs.md)

## Related

- [Ping snippets for 12 languages and tools](https://cronmissed.com/snippets.md)
- [Monitor scheduled jobs in Docker and Compose](https://cronmissed.com/guides/docker-compose.md)
- [Docker HEALTHCHECK guide and job pings](https://cronmissed.com/learn/docker-healthcheck.md)
- [Ping CronMissed from a shell script with curl](https://cronmissed.com/snippets/shell.md)
- [Kubernetes CronJob schedule: monitor every run](https://cronmissed.com/guides/kubernetes-cronjob.md)
- [How to stop overlapping cron job runs](https://cronmissed.com/learn/overlapping-cron-runs.md)
