age command validates that a container image is not older than a specified number of days. This ensures you’re using recent images with up-to-date dependencies and security patches.
Usage
Description
Theage command checks the image’s creation timestamp (from the OCI config’s created field) and calculates how many days have passed since that date. If the image age exceeds the configured maximum, the validation fails.
This check helps:
- Ensure images contain recent security patches
- Prevent deployment of outdated dependencies
- Maintain compliance with update policies
- Identify images that need rebuilding
Flags
Maximum age in days. Images older than this value will fail validation.Short form:
-aOutput format:
text or jsonShort form: -oColor output mode:
auto, always, neverSet log level: trace, debug, info, warn, error, fatal, panic
Examples
Basic usage with default age limit (90 days)
Custom age limit
Check OCI archive
JSON output
Output
Text Format
When validation passes:JSON Format
Exit Codes
| Code | Meaning | Example |
|---|---|---|
| 0 | Image is within age limit | Image created 30 days ago with max-age 90 |
| 1 | Image exceeds age limit | Image created 100 days ago with max-age 90 |
| 2 | Execution error | Image not found, invalid format |
Configuration
When using theall command, configure age validation in your config file:
Implementation Details
- Reads the
createdtimestamp from the OCI image configuration - Calculates age as
time.Since(created)in days (fractional) - Fails if creation date is zero/missing
- Age comparison:
age_days <= max_age - Works with all image transport types (registry, OCI layout, archives)
Common Issues
Image creation date is not set
Some images may not have a creation timestamp. This is rare but can happen with malformed images:Old base images
If you’re building on top of old base images, your final image will inherit that old creation date:FROM instruction and rebuild.
Best Practices
Set age limits based on your update cadence (e.g., 30 days for weekly builds, 90 days for monthly)
Combine with automated image rebuilds in CI/CD
Use stricter limits for production images
Consider different limits for base images vs. application images