registry command validates that a container image comes from a trusted registry based on a policy file. This ensures images are pulled only from approved sources.
Usage
Description
Theregistry command extracts the registry hostname from the image reference and validates it against a policy file. The policy can specify either trusted registries (allowlist) or excluded registries (blocklist).
This check helps:
- Enforce image provenance policies
- Prevent unauthorized image sources
- Ensure images come from approved registries
- Maintain supply chain security
- Comply with organizational security policies
Registry validation is automatically skipped for non-registry transports (OCI layout, archives)
Flags
Path to registry policy file (JSON or YAML format). Use
- to read from stdin.Short form: -rOutput format:
text or jsonShort form: -oColor output mode:
auto, always, neverSet log level: trace, debug, info, warn, error, fatal, panic
Policy File Format
The policy file must specify eithertrusted-registries (allowlist) or excluded-registries (blocklist), but not both.
Allowlist Mode (Trusted Registries)
Only registries in the list are allowed:Blocklist Mode (Excluded Registries)
All registries except those in the list are allowed:Examples
Validate with policy file
Validate fully qualified image
Policy from stdin
Dynamic policy generation
JSON output
Output
Text Format
When validation passes:JSON Format
Exit Codes
| Code | Meaning | Example |
|---|---|---|
| 0 | Registry is trusted or check skipped | docker.io with trusted-registries containing docker.io |
| 1 | Registry is not trusted | untrusted.com with trusted-registries not containing untrusted.com |
| 2 | Execution error | Invalid policy file, missing registry-policy flag |
Configuration
When using theall command, configure registry validation in your config file:
Inline Policy
You can embed the policy directly in the all-checks config:Implementation Details
- Extracts registry hostname from image reference
- Default registry is
docker.iofor images without explicit registry - Policy must specify exactly one mode (trusted or excluded)
- Registry matching is exact (no wildcards or patterns)
- Validation is skipped for OCI layout and archive transports
Common Issues
Missing registry-policy flag
--registry-policy flag with a valid policy file.
Both trusted and excluded specified
Neither trusted nor excluded specified
Registry mismatch
If your image reference doesn’t include a registry,docker.io is assumed:
Best Practices
Use allowlist mode (trusted-registries) for stricter security
Include all registries used by your base images
Document why each registry is trusted in comments
Regularly review and update your registry policy
Use environment-specific policies (dev vs prod)
Registry Hostname Extraction
check-image extracts the registry hostname from the image reference:| Image Reference | Extracted Registry |
|---|---|
nginx:latest | docker.io |
docker.io/nginx:latest | docker.io |
docker.io/library/nginx:latest | docker.io |
ghcr.io/user/app:v1 | ghcr.io |
registry.example.com:5000/app:latest | registry.example.com:5000 |
localhost:5000/test:latest | localhost:5000 |