Description
Validates that the container image has required labels (OCI annotations) with correct values. Supports three validation modes: existence checks, exact value matches, and pattern (regex) matches.Command Syntax
Flags
| Flag | Type | Required | Description |
|---|---|---|---|
--labels-policy | string | Yes | Labels policy file (JSON or YAML) |
--output / -o | string | No | Output format: text or json (default: text) |
--log-level | string | No | Log level (trace, debug, info, warn, error, fatal, panic) |
Validation Modes
1. Existence Check
Label must be present with any value (onlyname specified).
2. Exact Value Match
Label value must exactly match the specified string (name and value).
3. Pattern Match
Label value must match the regular expression (name and pattern).
Usage Examples
Basic Usage
JSON Output
Policy from stdin
OCI Layout
Example Output
Text Format (Success)
Text Format (Failure)
JSON Format (Success)
JSON Format (Failure)
Policy File Format
YAML Example
JSON Example
Policy Configuration Options
Label Requirement Object
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Label name to validate |
value | string | No | Expected exact value (exact match mode) |
pattern | string | No | Regular expression the value must match (pattern mode) |
value or pattern should be specified per label. If neither is specified, only existence is checked.
Exit Codes
| Exit Code | Meaning | Example | |-----------|---------|---------|----------| | 0 | All labels valid | All required labels present and valid | | 1 | Labels validation failed | Missing labels or invalid values | | 2 | Execution error | Invalid policy file, image not found |Common Label Patterns
Semantic Versioning
v1.2.3, 1.2.3, v1.2.3-alpha, 1.2.3+build.123
ISO 8601 Date (RFC3339)
2026-03-04T12:34:56Z
Git SHA
abc1234, abc1234567890abcdef1234567890abcdef1234
URL
https://github.com/user/repo, http://example.com:8080/path
Recommended OCI Labels
| Label | Description | Example | |-------|-------------|---------|----------| |org.opencontainers.image.created | Image creation timestamp | 2026-03-04T12:34:56Z |
| org.opencontainers.image.authors | Image authors | John Doe <[email protected]> |
| org.opencontainers.image.url | Project URL | https://github.com/user/repo |
| org.opencontainers.image.source | Source repository URL | https://github.com/user/repo |
| org.opencontainers.image.version | Image version | v1.2.3 |
| org.opencontainers.image.vendor | Vendor name | MyCompany |
| org.opencontainers.image.licenses | License identifier | MIT |
| org.opencontainers.image.title | Human-readable title | My Application |
| org.opencontainers.image.description | Description | A container for X |
Related Configuration Files
config/labels-policy.yaml- Sample labels policy in YAML formatconfig/labels-policy.json- Sample labels policy in JSON format
Notes
- Labels policy file is required for this command.
- Supports both file paths and stdin input (
-) for dynamic policy generation. - Inline policy support: policy can be embedded as object in all-checks config file.
- Regular expressions use Go regex syntax (RE2).
- Label names are case-sensitive.
- The check validates labels from
config.Config.Labelsin the image configuration.