Monitoring a Website
Docker environments are a good fit for small monitoring jobs that don't need a full workflow — checking that a site responds, and alerting a Slack channel when it doesn't. This guide walks through setting one up end to end: an environment, a schedule, and a Command that retries before giving up.
Create the environment
Go to Environments and click Add Environment.
Set Type to Docker and Source to Image.
Set Image to
curlimages/curl:latest— a minimal image that shipscurland nothing else, which is all this Command needs.Save the environment.
Write the schedule
Go to Schedules and click Add Schedule.
Set Environment to the Docker environment created above.
Under Environment Variables, add
SLACK_WEBHOOK_URLwith the webhook URL for the Slack channel that should receive the alert.Set Command to a retry loop that posts to Slack only once all attempts have failed:
bashURL="https://example.com" MAX_RETRIES=3 for i in $(seq 1 $MAX_RETRIES); do echo "Attempt $i/$MAX_RETRIES: checking $URL ..." if curl -sf -o /dev/null "$URL"; then echo "Success: $URL is reachable" exit 0 fi echo "Attempt $i failed" sleep 5 done echo "All $MAX_RETRIES attempts failed, notifying Slack" curl -X POST -H 'Content-type: application/json' \ --data "{\"text\":\"$URL is not responding after $MAX_RETRIES attempts\"}" \ "$SLACK_WEBHOOK_URL" exit 1Exiting non-zero on final failure also marks the run as
failed, so Runner's own run history and any Notifications you've enabled reflect the outage too — the Slack post is an additional, faster channel.Set Schedule to how often the check should run, for example
*/5 * * * *for every 5 minutes.Save the schedule and set it to Active.
Adjusting the example
- Swap
curlimages/curlfor apythonornodeimage and rewrite the Command in that language — see the examples in Schedules. - If the check needs a tool the image doesn't include, install it via the environment's Additional Dockerfile Instructions instead of switching images — see Environments.
- To alert multiple channels or add email, extend the final
curlcall or enable the schedule's own Notify on failed runs toggle instead of maintaining the logic in the Command.