zot Registry Documentation
repository·main·Indexed 25 days ago
https://github.com/project-zot/zotzot is a production-ready, vendor-neutral OCI image registry implementing the OCI image format and distribution specification. Documentation covers registry configuration (storage, network, TLS), retention policies for tags and untagged manifests, and the use of the zb benchmarking tool for measuring push, pull, and sync performance.
What's inside zot
- zot is a production-ready, vendor-neutral OCI (Open Container Initiative) image registry. It is designed to store images following the OCI image format and uses the distribution specification for on-the-wire communication. It is intended for users needing a compliant registry for container images.
Overview of the `search` component
mainThe
searchcomponent provides enhanced registry search capabilities using a GraphQL backend. It allows for complex queries including searching by digest, CVE vulnerability status, image relationships (base/derived), and global registry scans.To interact with the search component, you can send GraphQL queries via HTTP POST requests to the endpoint:
http://<host>:<port>/v2/_zot/ext/search.Example using
curl:curl -X POST -H "Content-Type: application/json" --data '{ "query": "{ ImageListForCVE (id:\"CVE-2002-1119\") { Results { RepoName Tag } } }" }' http://localhost:8080/v2/_zot/ext/searchUse the `mgmt` component for configuration management
mainThe
mgmtcomponent provides an endpoint for managing and inspecting the current Zot configuration. The response returned by the endpoint is subject to user privileges:- Unauthenticated and Authenticated users: Receive a stripped version of the configuration.
- Admins: Receive the full configuration (note: password hiding for admins is currently not implemented).
If
ldaporhtpasswdare enabled, the response will include{"htpasswd": {}}(or similar for LDAP) to indicate that clients can authenticate using those specific methods. Any key present under the'auth'object in the response signifies that the corresponding authentication method is enabled.Access zot extension components via API endpoints
mainThe
zotextension provides several specialized capabilities accessible through the/v2/_zotendpoint prefix. These components allow for enhanced registry search, configuration management, user preference updates, and image trust management (via cosign or notation).Component Endpoint Description search/v2/_zot/ext/searchEfficient and enhanced registry search using a GraphQL backend mgmt/v2/_zot/ext/mgmtConfiguration management userprefs/v2/_zot/ext/userprefsChange user preferences imagetrust(cosign)/v2/_zot/ext/cosignCosign public key management imagetrust(notation)/v2/_zot/ext/notationNotation certificate management Compare zot with docker distribution
mainzot is a container registry designed for minimal builds, OCI conformance, and built-in features that often require auxiliary components in other registries like
docker distribution.Key advantages of zot include:
- Storage Layout: Uses the
ociv1image layout. - Security: Built-in authentication, authorization, vulnerability scanning, and image signature support (including Notation and Cosign).
- Maintenance: Inline garbage collection and storage deduplication (unlike
docker distributionwhich may require server shutdown for GC). - Management: Supports deleting by tag and includes a built-in UI.
- Compliance: Fully conforms to the distribution-spec.
- Storage Layout: Uses the
Configure storage types in zot
mainzot supports two types of underlying filesystems for storage:
- local: A locally mounted filesystem.
- remote: A remote filesystem, such as AWS S3.
Ensure your configuration specifies the appropriate storage type based on your environment requirements.
Configure tag and untagged manifest retention policies
mainZot allows you to define retention rules to govern how many tags or how long certain manifests are kept. Retention is configured via the
retentionobject in the configuration file.Retention Logic
- OR Logic: If ANY rule in a policy is met, the tag/manifest is retained.
- Repository Matching: Uses glob patterns (e.g.,
infra/*,tmp/**). - Tag Matching: Uses regex patterns (e.g.,
v2.*). - Policy Selection: A repository matches the first policy in the
policieslist that matches its name. - Default Behavior: If a repository does not match any policy in the list, it and all its tags are retained (nothing is deleted). However, if you define policies, any tag that does not match at least one
KeepTagsrule within a matched policy will be removed. - Untagged Manifests: Controlled by
deleteUntagged(master switch) andkeepUntaggedrules.keepUntaggedrules require the metadata database to be available.
Available Rules
The following rules can be used for both
KeepTagsandkeepUntagged:mostRecentlyPushedCount: x: Retain the topxmost recently pushed tags.mostRecentlyPulledCount: x: Retain the topxmost recently pulled tags.pulledWithin: x hours: Retain tags pulled within the lastxhours.pushedWithin: x hours: Retain tags pushed within the lastxhours.
"retention": { "dryRun": false, "delay": "24h", "policies": [ { "repositories": ["infra/*"], "deleteUntagged": true, "KeepTags": [{ "patterns": ["v2.*"] }] } ] }JWT Token Requirements for AWS Secrets Manager
mainWhen using AWS Secrets Manager for key retrieval, every JWT presented to Zot must include a
kid(Key ID) header. Zot uses thiskidto look up the corresponding public key in the secret fetched from AWS.Example JWT Header:
{ "alg": "EdDSA", "kid": "key-id-1", "typ": "JWT" }How OCI digest prediction works for on-demand sync
mainZot uses
predictOCIDigestto determine if an image needs to be re-synced by predicting the OCI digest it will have after conversion viaregclient'smod.WithManifestToOCIandmod.WithManifestToOCIReferrers.This mechanism allows Zot to perform a "skip check" by comparing the local stored digest (the OCI layout digest) against the remote "would-be" digest (the predicted OCI digest). This prevents endless resync loops that occur when comparing raw upstream Docker digests against local OCI-converted digests.
Key Concepts
- Prediction vs. Actual Sync:
predictOCIDigestis a lightweight, in-memory mirror of the conversion logic. It performs a manifest tree walk using onlyManifestGetcalls. It does not fetch config blobs, layer blobs, or referrer lists, making it significantly cheaper than a fullmod.ApplyorImageCopy. - The
isConvertedFlag: The predictor returns anisConvertedboolean. This istrueifregclientwould change any manifest in the tree (e.g., changing media types inside the JSON). IfisConvertedisfalse, Zot can skip the expensivemod.Applystep during sync. - Manifest Rewriting: Even if a manifest's top-level
mediaTypeis OCI,WithManifestToOCImay still rewrite interior descriptor media types (forconfigorlayers) inside the JSON. Therefore, the predictor must fetch the manifest JSON for every node in the tree to ensure accuracy.
- Prediction vs. Actual Sync:
Implement a Generator for the scheduler
mainA Generator is an abstraction used to produce tasks one by one. To create a custom generator, you must implement the following four methods:
Next() (Task, error): Implements the logic to generate the next task. It should return tasks sequentially until no more are available. The returnedTaskmust implement theDoWork(ctx context.Context)method.IsDone() bool: Returnstruewhen the generator has finished all work and has no more tasks to produce.IsReady() bool: Returnstrueif the generator is ready to produce a new task. This is used to introduce delays between task generations.Reset(): Resets the generator to its initial state. This is used by the scheduler for periodic generators to restart the generation cycle after a specified interval.
Implement a Task for the scheduler
mainA Task represents a single unit of work. To create a custom task, you must implement the following three methods:
DoWork(ctx context.Context) error: Contains the actual logic to be executed when the scheduler runs the task.Name() string: Returns the name of the task.String() string: Returns a description of the task, primarily used for debugging and identification during execution.
Manage Session Storage and Security
mainZot uses session cookies for authenticated users.
Session Drivers:
local: Uses the filesystem (for local storage) or in-memory (for cloud storage). This is the default.redis: Use a Redis instance for shared sessions across multiple Zot instances. Requiresurlandkeyprefix.
Securing Sessions: To prevent session hijacking/tampering, use
sessionKeysFileto provide keys for HMAC hashing and AES encryption. The file should contain a JSON object withhashKeyand optionallyencryptKey.hashKey: Used for HMAC. Recommended length: 32 or 64 bytes.encryptKey: Used for AES encryption. Valid lengths: 16, 24, or 32 bytes.
"auth": { "sessionDriver": { "name": "redis", "url": "redis://localhost:6379", "keyprefix": "zotsession" }, "sessionKeysFile": "/home/user/keys" }