Skip to main content
Check Image supports multiple output formats and color modes to suit different use cases, from interactive terminal use to CI/CD pipelines and programmatic parsing.

Output Formats

Check Image supports two output formats controlled by the --output (or -o) flag:

Text (Default)

Human-readable output with colors and formatting for terminal use.

JSON

Machine-readable JSON for scripting and programmatic parsing.

Text Output

Text output is designed for human readability with colored status indicators, structured information, and clear error messages.
check-image age nginx:latest --max-age 90
Example Output:
Checking age of image nginx:latest
Image creation date: 2026-02-04T23:53:09Z
Image age: 28 days
✓ Image is less than 90 days old
Validation succeeded
Checking if image nginx:latest is configured to run as a non-root user
✓ Image runs as non-root user
Validation succeeded

JSON Output

JSON output provides structured data for scripting, automation, and integration with other tools.
check-image age nginx:latest --max-age 90 --output json
check-image size nginx:latest --max-size 100 -o json
Example JSON Output:
{
  "check": "age",
  "image": "nginx:latest",
  "passed": true,
  "message": "Image is less than 90 days old",
  "details": {
    "created-at": "2025-12-01T00:00:00Z",
    "age-days": 75,
    "max-age": 90
  }
}
All JSON keys use kebab-case (e.g., age-days, max-size-mb, created-at) for consistency across the tool.

JSON Schema

All JSON output follows a consistent schema:
interface CheckResult {
  check: string;           // Check name (e.g., "age", "size")
  image: string;           // Image reference
  passed: boolean;         // Validation result
  message: string;         // Human-readable message
  details?: object;        // Check-specific details
  error?: string;          // Error message (if execution failed)
}
interface AllResult {
  image: string;           // Image reference
  passed: boolean;         // Overall validation result
  checks: CheckResult[];   // Array of individual check results
  summary: {
    total: number;         // Total checks attempted
    passed: number;        // Number of checks passed
    failed: number;        // Number of checks failed
    errored: number;       // Number of checks that errored
    skipped?: string[];    // Names of skipped checks
  };
}

Color Modes

Color output is controlled by the --color flag and only applies to text output.
--color
string
default:"auto"
Color output mode: auto, always, or never.

Auto Mode (Default)

Automatically detects whether stdout is a terminal and respects environment variables.
check-image age nginx:latest --color auto
Auto mode behavior:
1

Terminal Detection

Colors are enabled if stdout is a TTY (interactive terminal).
2

NO_COLOR Environment Variable

If NO_COLOR is set (any non-empty value), colors are disabled.
3

CLICOLOR_FORCE Environment Variable

If CLICOLOR_FORCE=1, colors are enabled even in non-TTY environments.
check-image age nginx:latest

Always Mode

Forces color output regardless of terminal detection.
check-image age nginx:latest --color always
Even with --color always, the NO_COLOR environment variable is still respected for no-color.org compliance.
check-image age nginx:latest --color always | less -R

Never Mode

Disables color output completely.
check-image age nginx:latest --color never
check-image age nginx:latest --color never
Use --color never in CI/CD logs for cleaner, grep-friendly output without ANSI escape codes.

Exit Codes

Check Image uses exit codes to indicate the result of validation:
Exit Code 0
Success
Validation succeeded or no checks ran (skipped).
Exit Code 1
Validation Failed
One or more checks failed validation (image does not meet requirements).
Exit Code 2
Execution Error
Tool encountered an error and could not complete validation (invalid config, image not found, etc.).

Exit Code Examples

check-image age nginx:latest --max-age 90
echo $?  # Output: 0
Image is less than 90 days old → validation succeeded.

Exit Code Precedence

In the all command, if multiple checks produce different results, the exit code follows this priority:
1

Execution Error (Exit 2) - Highest Priority

If any check encounters an execution error, exit code 2 is returned.
2

Validation Failed (Exit 1)

If one or more checks fail validation but no execution errors occur, exit code 1 is returned.
3

Validation Succeeded (Exit 0)

If all checks pass, exit code 0 is returned.
4

Validation Skipped (Exit 0) - Lowest Priority

If no checks ran, exit code 0 is returned.
Example: Mixed results
check-image all nginx:latest --skip registry,labels
# 6 checks passed, 2 checks failed, 0 errors → Exit 1

check-image all nginx:latest --registry-policy invalid.json
# Some checks passed, some failed, 1 execution error → Exit 2

Using Exit Codes in Scripts

if check-image age nginx:latest --max-age 30; then
    echo "Image is fresh"
else
    echo "Image is too old or validation failed"
fi

Output Redirection

Check Image writes different types of output to different streams:
  • Text output (validation results)
  • JSON output
  • Final status messages (“Validation succeeded”, “Validation failed”)
  • Log messages (controlled by --log-level)
  • Error details
  • Warnings
check-image age nginx:latest > validation-results.txt

Log Levels

Control verbosity of diagnostic logging with the --log-level flag:
--log-level
string
default:"info"
Log level: trace, debug, info, warn, error, fatal, panic.
check-image age nginx:latest --log-level info
Use --log-level debug when troubleshooting authentication or image retrieval issues.

Best Practices

Use JSON in CI/CD

JSON output is ideal for automated parsing, reporting, and integration with other tools.
check-image all $IMAGE -o json > results.json
jq '.summary' results.json

Use text for terminals

Text output with colors provides better readability for interactive use and debugging.
check-image age nginx:latest --output text

Disable colors in CI/CD

Use --color never in CI/CD logs to avoid ANSI escape codes in log files.
check-image all $IMAGE --color never

Check exit codes

Always check exit codes in scripts to distinguish between validation failures and execution errors.
if ! check-image all $IMAGE; then
    echo "Validation failed"
    exit 1
fi

Commands

Explore all available validation commands

Configuration Files

Understand policy and configuration file formats

GitHub Action

Use Check Image in GitHub Actions workflows

CI/CD Integration

Integrate Check Image into your CI/CD pipeline

Build docs developers (and LLMs) love