# Container Repos

Container Repos are a repo type on the Hugging Face Hub for Docker and other [OCI](https://opencontainers.org/) images, served by the Hugging Face container registry, `cr.hf.co`, and powered by the [Xet](./xet/index) storage backend. They live in your organization next to its models, datasets and Spaces.

Push and pull images with [`hf container`](#pushing-and-pulling-with-hf-container), the recommended client, or with Docker and any other OCI client, and browse their tags on the Hub.

> [!NOTE]
> Container Repos are in private beta: [contact us](https://huggingface.co/contact/sales) to enable them for your organization.

> [!TIP]
> Images count toward your organization's Hub storage. See [Pricing](#pricing) for examples, and [hf.co/storage](https://huggingface.co/storage) for pricing details.

## Why Host Containers on the Hub

- **Next to the rest of your work**: images live in your organization, with the same members, roles, visibility and [User Access Tokens](./security-tokens) as your other repos. There is no separate registry account to manage.
- **On your Hub storage**: images count toward your organization's [storage](#pricing), public or private, with no separate registry bill.
- **Served by the Hub's CDN**: layers are stored on Xet and served through the Hugging Face CDN wherever you run them, with egress included in your plan.
- **A standard registry**: Docker, Podman, containerd and Kubernetes, crane, skopeo, ORAS, Helm and cosign work as they are, with multi-arch images and referrers (signatures, SBOMs and other artifacts attached to an image).
- **Faster with `hf container`**: the Hub's own client uploads only the parts of a layer that changed since the previous version, and pulls layers straight from Xet with nothing to decompress.
- **Cleaned up for you**: images that no tag points to are deleted automatically, so your storage follows what you tag.

## Creating a Repository

### From the Hub UI

1. Navigate to [huggingface.co/new-container](https://huggingface.co/new-container).

2. Specify the organization that owns the repository.

3. Enter a repository name and, optionally, a short description.

4. Choose whether the repository should be public or private.

### From the API

```bash
curl -X POST https://huggingface.co/api/containers/my-org/my-app \
  -H "Authorization: Bearer $HF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"private": true}'
```

Create the repository before pushing: a push to a missing one fails with `NAME_UNKNOWN`. Who can pull and push follows the repository's visibility and each member's role in the organization, or in its Resource Group: see [Access Control](./containers-access).

## Browsing Images on the Hub

Every repository has a page on the Hub listing its tags, at `https://huggingface.co/containers/<owner>/<name>`.

## Pushing and Pulling with `hf container`

[`hf container`](https://github.com/huggingface/hf-container), an extension of the `hf` CLI, is the recommended client. It stores layers uncompressed on [Xet](./xet/index): a push only uploads the parts of each layer that changed since the previous version, and a pull downloads layers over many connections and unpacks them as they arrive, with nothing to decompress.

```bash
hf extensions install hf-container
hf auth login                                   # or set HF_TOKEN
hf container build -t cr.hf.co/my-org/my-app:v2 .   # build from your Dockerfile and push
hf container push cr.hf.co/my-org/my-app:v2         # or push a local image with that name
hf container pull cr.hf.co/my-org/my-app:v2
hf container run --rm cr.hf.co/my-org/my-app:v2     # pull if needed, then docker run
```

It uses your Hugging Face [User Access Token](./security-tokens) (`read` to pull, `write` to push) and needs Docker with the [containerd image store](https://docs.docker.com/engine/storage/containerd/), on Linux or macOS. Any client can pull the images it pushes, and it pulls images pushed by any client.

Because `hf container` stores layers uncompressed, the images it pushes get different digests than with `docker push`, and [count for more storage](#pricing). To keep the `docker push` digests, for signatures or deployments pinned by digest, use `hf container push --preserve-digests`. It is slower: a changed layer is then uploaded in full, and pulls decompress it, as with `docker push`.

## Copying Images from Other Registries

`hf container copy` brings an image from another registry, such as Docker Hub, ghcr.io, quay.io or registry.k8s.io, to a container repository, without pulling it into Docker first:

```bash
hf container copy vllm/vllm-openai:v0.11.0 cr.hf.co/my-org/vllm-openai    # from Docker Hub, keeps the tag
hf container copy registry.k8s.io/pause:3.10 cr.hf.co/my-org/pause:3.10
```

Name the source as for `docker pull`: without a registry host, it is on Docker Hub. For a private source, log in to its registry first with `docker login`. The destination repository must [exist](#creating-a-repository); a destination without a tag takes the source's tag. Every platform of a multi-arch image is copied.

Layers are stored uncompressed, as with `hf container push`: the copy gets different digests than its source and [counts for more storage](#pricing). To keep the source's digests, use `--preserve-digests`.

## Using Docker and Other OCI Clients

The registry works with any OCI client. Log in with your Hugging Face username and a [User Access Token](./security-tokens) as the password: `read` to pull, `write` to push. Public images can be pulled without logging in.

```bash
echo $HF_TOKEN | docker login cr.hf.co -u <username> --password-stdin
docker tag my-app cr.hf.co/my-org/my-app:v1
docker push cr.hf.co/my-org/my-app:v1
docker pull cr.hf.co/my-org/my-app:v1
```

Other OCI clients work the same way. Helm appends the chart name to the URL: `helm push mychart-0.1.0.tgz oci://cr.hf.co/my-org` pushes to `my-org/mychart`, which must exist beforehand.

## Pulling from Kubernetes

Store a `read` token in a pull secret, then reference it from your pods:

```bash
kubectl create secret docker-registry hf-registry \
  --docker-server=cr.hf.co \
  --docker-username=<username> \
  --docker-password=$HF_TOKEN
```

```yaml
apiVersion: v1
kind: Pod
metadata:
  name: my-app
spec:
  containers:
    - name: my-app
      image: cr.hf.co/my-org/my-app:v1
  imagePullSecrets:
    - name: hf-registry
```

Public images need no pull secret, but with one, pulls count against your account's rate limits instead of your cluster's IP address. Images pushed with `hf container` pull the same way.

## Pushing from GitHub Actions

Add your username and a `write` token as repository secrets, here `HF_USERNAME` and `HF_TOKEN`, then log in and push:

```yaml
- uses: docker/login-action@v4
  with:
    registry: cr.hf.co
    username: ${{ secrets.HF_USERNAME }}
    password: ${{ secrets.HF_TOKEN }}
- uses: docker/setup-buildx-action@v4
- uses: docker/build-push-action@v7
  with:
    push: true
    tags: cr.hf.co/my-org/my-app:${{ github.sha }}
```

## Deleting Images

On the Hub, remove a tag using **Delete this tag** in its menu, on the image or tag's page. With [`hf container`](#pushing-and-pulling-with-hf-container), remove an image's tags, then delete it by digest:

```bash
hf container untag cr.hf.co/my-org/my-app:v1                # prints the image's digest
hf container delete cr.hf.co/my-org/my-app@sha256:<digest>
```

Removing its tags is enough: [garbage collection](#garbage-collection) deletes the image a few hours later. Deleting it by digest removes it right away. If something still references the image, such as another tag, the deletion is refused and lists what to remove first. Deleting a multi-arch image leaves its platform images to garbage collection.

Other clients that delete tags work too, such as crane:

```bash
crane delete cr.hf.co/my-org/my-app:v1
```

## Garbage Collection

The registry deletes images that no tag points to anymore, directly or through a multi-arch image, such as the previous `latest` after a new push. It also deletes the layers that no remaining image uses. To keep pulling an image by digest, keep a tag on it.

## Limits

- Image names are `cr.hf.co/<namespace>/<name>`, in lowercase.
- Layers up to 100 GB, manifests up to 4 MiB.
- Tag lists can take a few seconds to show a new tag.
- Pulls count toward your [Hub rate limits](./rate-limits) as resolver requests: log in so they count against your account rather than your IP address.

## Pricing

Images are billed as storage of the organization that owns them: private storage for private repositories, public storage for public ones, shared with its models, datasets and buckets. Each repository counts a layer once, however many tags and images use it, at the size it was pushed: compressed with `docker push` and other OCI clients, uncompressed with `hf container`, typically two to three times as much, sometimes more.

Pulls count toward the egress allowance included in your plan, shown in [Download Analytics](./download-analytics).

Private storage is included in every plan: 100 GB for a free organization, and 1 TB per seat for Team and Enterprise organizations. Beyond it, Team and Enterprise organizations pay $18 per TB per month, with discounts at volume; a free organization needs to upgrade. For example:

- 20 tagged versions of an image pushed as 5 GB, all sharing the same 4 GB base layers, take 4 + 20 × 1 = 24 GB: they fit in a free organization's private storage.
- A Team organization with 10 members includes 10 TB of private storage. 12 releases of a vLLM image, about 9 GB each compressed and 21 GB uncompressed, use 110 GB of it pushed with `docker push`, 250 GB with `hf container`.

For usage above the [free tier](./storage-limits#storage-plans), see [hf.co/storage](https://huggingface.co/storage). For general billing information, see the [Billing](./billing) documentation.
