zot Registry Documentation

repository·main·Indexed 25 days ago

https://github.com/project-zot/zot

zot 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.

Tokens
34.6K
Snippets
85
Records
192
Agent score
81%

What's inside zot

  1. Overview of the `search` component

    main

    The search component 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/search
  2. Use the `mgmt` component for configuration management

    main

    The mgmt component 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 ldap or htpasswd are 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.

  3. Access zot extension components via API endpoints

    main

    The zot extension provides several specialized capabilities accessible through the /v2/_zot endpoint prefix. These components allow for enhanced registry search, configuration management, user preference updates, and image trust management (via cosign or notation).

    ComponentEndpointDescription
    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
  4. Compare zot with docker distribution

    main

    zot 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 ociv1 image 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 distribution which may require server shutdown for GC).
    • Management: Supports deleting by tag and includes a built-in UI.
    • Compliance: Fully conforms to the distribution-spec.
  5. Configure storage types in zot

    main

    zot supports two types of underlying filesystems for storage:

    1. local: A locally mounted filesystem.
    2. remote: A remote filesystem, such as AWS S3.

    Ensure your configuration specifies the appropriate storage type based on your environment requirements.

  6. Configure tag and untagged manifest retention policies

    main

    Zot allows you to define retention rules to govern how many tags or how long certain manifests are kept. Retention is configured via the retention object 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 policies list 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 KeepTags rule within a matched policy will be removed.
    • Untagged Manifests: Controlled by deleteUntagged (master switch) and keepUntagged rules. keepUntagged rules require the metadata database to be available.

    Available Rules

    The following rules can be used for both KeepTags and keepUntagged:

    • mostRecentlyPushedCount: x: Retain the top x most recently pushed tags.
    • mostRecentlyPulledCount: x: Retain the top x most recently pulled tags.
    • pulledWithin: x hours: Retain tags pulled within the last x hours.
    • pushedWithin: x hours: Retain tags pushed within the last x hours.
    "retention": {
        "dryRun": false,
        "delay": "24h",
        "policies": [
            {
                "repositories": ["infra/*"],
                "deleteUntagged": true,
                "KeepTags": [{
                    "patterns": ["v2.*"]
                }]
            }
        ]
    }
  7. How OCI digest prediction works for on-demand sync

    main

    Zot uses predictOCIDigest to determine if an image needs to be re-synced by predicting the OCI digest it will have after conversion via regclient's mod.WithManifestToOCI and mod.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: predictOCIDigest is a lightweight, in-memory mirror of the conversion logic. It performs a manifest tree walk using only ManifestGet calls. It does not fetch config blobs, layer blobs, or referrer lists, making it significantly cheaper than a full mod.Apply or ImageCopy.
    • The isConverted Flag: The predictor returns an isConverted boolean. This is true if regclient would change any manifest in the tree (e.g., changing media types inside the JSON). If isConverted is false, Zot can skip the expensive mod.Apply step during sync.
    • Manifest Rewriting: Even if a manifest's top-level mediaType is OCI, WithManifestToOCI may still rewrite interior descriptor media types (for config or layers) inside the JSON. Therefore, the predictor must fetch the manifest JSON for every node in the tree to ensure accuracy.
  8. Implement a Generator for the scheduler

    main

    A Generator is an abstraction used to produce tasks one by one. To create a custom generator, you must implement the following four methods:

    1. Next() (Task, error): Implements the logic to generate the next task. It should return tasks sequentially until no more are available. The returned Task must implement the DoWork(ctx context.Context) method.
    2. IsDone() bool: Returns true when the generator has finished all work and has no more tasks to produce.
    3. IsReady() bool: Returns true if the generator is ready to produce a new task. This is used to introduce delays between task generations.
    4. 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.
  9. Implement a Task for the scheduler

    main

    A Task represents a single unit of work. To create a custom task, you must implement the following three methods:

    1. DoWork(ctx context.Context) error: Contains the actual logic to be executed when the scheduler runs the task.
    2. Name() string: Returns the name of the task.
    3. String() string: Returns a description of the task, primarily used for debugging and identification during execution.
  10. Manage Session Storage and Security

    main

    Zot 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. Requires url and keyprefix.

    Securing Sessions: To prevent session hijacking/tampering, use sessionKeysFile to provide keys for HMAC hashing and AES encryption. The file should contain a JSON object with hashKey and optionally encryptKey.

    • 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"
    }