---
title: "ezgh registry cache-rules create"
description: "Create a pull-through cache rule and grant it its credentials."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.ezghcloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ezgh registry cache-rules create

{/* Generated by ezgh-cli's internal/tools/clidocs from the ezgh command tree. Don't edit: change the command's help in ezgh-cli and regenerate. */}

```sh
ezgh registry cache-rules create --prefix <prefix> --upstream docker-hub --secret <secret> [--description d] [flags]
```

Create a pull-through cache rule: images pulled at &lt;host&gt;/&lt;prefix&gt;/&lt;namespace&gt;/&lt;repository&gt; come from the upstream (only docker-hub for now) on first pull and are kept in the project. Official Docker Hub images are under library/ (&lt;host&gt;/&lt;prefix&gt;/library/nginx).

`--secret` is an EZGH Secrets secret with the fields username and accessToken (a Docker Hub access token), by name or ID in the project, or by resource name. Creating the rule then grants it read access to the secret in EZGH Secrets, as you: that needs secrets.grants.create and secrets.versions.access on it. If the grant fails the rule stays; run update with `--secret` to grant it again.

Part of [`ezgh registry cache-rules`](/cli/reference/registry-cache-rules).

## Examples

```sh
ezgh registry cache-rules create --prefix docker-hub --upstream docker-hub --secret dockerhub/build-bot
```

## Flags

| Flag | Type | Default | Description |
| --- | --- | --- | --- |
| `--description` | string |  | what it's for |
| `--prefix` | string |  | the first part of every image name pulled through it, such as docker-hub |
| `--secret` | string |  | the EZGH Secrets secret with username and accessToken: a name, ID or resource name |
| `--upstream` | string |  | where images come from: docker-hub |

This command also takes the [global flags](/cli/reference#global-flags).

Source: https://docs.ezghcloud.com/cli/reference/registry-cache-rules-create/index.mdx
