Bash public

Docker Image Age

Share this script safely, inspect its metadata, and copy the exact command you need.

Dashboard

Ready to run

One-liner

Copy the command, then review before execution.
curl -fsSL https://runny.sh/r/GC4AGK3DP0ST | bash

Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.372

At a glance

Script metadata

Slug
GC4AGK3DP0ST
Fetches
0
Size
1440 B · 54 lines
Expires
never
Last fetch
Created
2026-09-07 00:36:00.026
Description
Images older than 90 days

Readable before runnable

Preview

#!/usr/bin/env bash
# Docker image age
# Read-only: lists local images older than 90 days. Does not prune or delete.
# Exit 0 if none are that old, 1 if stale images exist, 2 if docker is unreachable.
# Hosted on Runny.sh. Review the script page before you run it.

set -u

status=0
note() { printf '%s\n' "$*"; }
bump() {
  case $1 in
    crit) status=2 ;;
    warn) [ "$status" -lt 1 ] && status=1 ;;
  esac
}

note "=== Docker images older than 90 days ==="
if ! command -v docker >/dev/null 2>&1; then
  note "docker:   CLI not found in PATH"
  note "Result: WARNING"
  exit 1
fi
if ! docker info >/dev/null 2>&1; then
  note "Daemon:   unreachable"
  note "Result: CRITICAL"
  exit 2
fi

total=$(docker images -q 2>/dev/null | awk 'END {print NR}')
note "Images:   ${total} local"
old=$(docker images --filter 'until=90d' --format '{{.Repository}}:{{.Tag}}  {{.ID}}  {{.CreatedSince}}' 2>/dev/null || true)
if [ -z "${old}" ]; then
  note "Older than 90 days: none"
  note "          OK"
else
  count=$(printf '%s\n' "$old" | awk 'NF {n++} END {print n+0}')
  note "Older than 90 days: ${count}"
  printf '%s\n' "$old" | awk 'NR <= 20 {print "  " $0}'
  if [ "$count" -gt 20 ]; then
    note "  ... $((count - 20)) more"
  fi
  note "          WARNING: stale images still on disk"
  bump warn
fi
note ""

case $status in
  0) note "Result: HEALTHY" ;;
  1) note "Result: WARNING" ;;
  *) note "Result: CRITICAL" ;;
esac
exit "$status"

Raw endpointhttps://runny.sh/r/GC4AGK3DP0ST

See something unsafe?

Report this script

Tell us why it should come down. Anyone can also report a URL at /abuse.

Restore revision