Skip to content
ExplainedDevOps

Hugging Face Docker registry opens with a way to ditch CI secrets

The Hugging Face Docker registry now has account-level activation. Here's who can push, who can pull, and how CI can avoid a saved token.

By DC Team · · 6 min read

Official Hugging Face and Docker logos. Push containers without saving secret tokens. A temporary key connects a build to a container repository.

The Hugging Face Docker registry is now something users can switch on in account settings. Hugging Face's December 4 changelog opens Container Repos activation to personal accounts and organization admins, putting Docker and other OCI images on the Hub at cr.hf.co. For a team already publishing model weights there, the software that runs those weights can now live beside them.

The useful operational detail is that a build does not necessarily need a saved Hugging Face access token. A configured Trusted Publisher lets CI exchange its identity for a short-lived token scoped to one repository. Teams without that setup can use the familiar username-and-access-token login.

Our recommendation: trial one existing inference image before moving your release pipeline. Decide who can publish it, whether its existing digest must survive the move, and which releases need to remain available for rollback. Those decisions matter more than changing the registry hostname.

Who can push to the Hugging Face Docker registry?

First distinguish enabling the feature from accessing an image. The launch notice says users can enable Container Repos in personal settings, while organization admins can do so in organization settings. The current registry documentation now points to the same settings toggles. Check those controls in the account that will own the image before planning a migration.

The dedicated container access-control documentation separates public pulls, private pulls and writes. Here is the practical permission map:

OperationAccess neededCredential path
Pull a public imageAnyoneAnonymous pulling is supported
Pull a private organization imageRepository read accessRead-capable user token, or a configured read-only repo publisher
Push an imageRepository write accessWrite-capable user token, or a configured repo publisher
Pull a private image inside a Resource GroupGroup access, or organization admin accessA token with the corresponding access

On Team and Enterprise plans, a Resource Group's role replaces the member's organization role for a container repository assigned to that group. An employee's presence in the organization alone is therefore insufficient evidence that their deployment credential can read a particular private image. Container permissions and Resource Groups.

With a personal access token, both the token's scope and its owner's access matter. A write token does not elevate someone who lacks permission to write the target repository. Hugging Face's token documentation recommends separate tokens per application and fine-grained tokens for production. Keep publishing and deployment credentials separate when choosing that route.

CI can exchange identity instead of storing a password

The current registry instructions explicitly support publishing from GitHub Actions through a Trusted Publisher. Configure that publisher on the destination container repository before running the workflow. A successful login is only useful after the repository itself exists.

The Trusted Publishers security model gives exchanged tokens a 60-minute lifetime. Repo publishers are scoped to one repository. A read-only publisher can pull but cannot push. For GitHub Actions, the CLI obtains the identity token automatically when the job has id-token: write and HF_OIDC_RESOURCE identifies the target.

Pin the publisher to your GitHub repository and add branch and workflow claims. Treat those settings as release permissions: a narrowly configured publisher makes it easier to answer which workflow is allowed to publish which artifact. An account-level identity for reading gated models serves a different purpose. Use the container repository as the resource for this publishing job. Publisher configuration and resource types.

This example adapts Hugging Face's documented Docker login path into a manual workflow. Before copying it, replace both my-org/my-app references, create that container repository, and configure a GitHub Trusted Publisher matching this repository, branch and workflow file. It assumes a Dockerfile in the checkout and a runner with Docker. We checked the example against the documentation; we did not execute an authenticated push.

name: Publish container to Hugging Face
on:
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - name: Install Hugging Face CLI
        run: |
          curl -LsSf https://hf.co/cli/install.sh | bash
          echo "$HOME/.local/bin" >> "$GITHUB_PATH"
      - name: Authenticate, build and push
        env:
          HF_OIDC_RESOURCE: containers/my-org/my-app
          IMAGE: cr.hf.co/my-org/my-app
        run: |
          set -euo pipefail
          hf auth token | docker login cr.hf.co -u oauth2 --password-stdin
          docker build -t "$IMAGE:$GITHUB_SHA" .
          docker push "$IMAGE:$GITHUB_SHA"

Notice the two different strings: the exchange resource starts with containers/, while the image reference starts with cr.hf.co/. Mixing them up is an avoidable configuration error. The workflow logs into Docker with the exchanged credential through standard input. It does not print the token as a separate diagnostic step.

Without a publisher, supply a write-capable user token as a CI secret and log into cr.hf.co using the Hugging Face username with that token as the password. Pull-only consumers need read access. Those are the registry's documented Docker authentication rules.

Faster uploads can change the artifact you pin

The official hf-containers repository describes a different transfer path from ordinary Docker pushes. Its client stores layers uncompressed and uses Xet to reuse unchanged chunks. That can avoid uploading an entire rebuilt layer when only part changed.

It also changes digests when converting compressed layers. Use hf containers push --preserve-digests when existing signatures or digest-pinned deployments must keep referring to the same artifact. The project documents the trade-off: preserving compressed content gives up chunk-level deduplication for those layers. The client also requires Docker's containerd image store for its normal build, push and pull workflow. Implementation, digest preservation and requirements.

Choose the transfer client before collecting your migration results. A comparison between a compressed Docker upload and an uncompressed optimized upload changes more than the host serving the image. Record the client, image digest, layer sizes, cache state and runner location. Otherwise a faster second push can tell you more about reused data than about a registry's general performance.

For signed releases, make digest preservation a pass condition in the pilot. For frequently rebuilt development images, measure whether reduced upload work is worth the stored size. Those workloads can justify different choices within the same team.

Storage and rollback need their own budget

Container layers count toward Hub storage, and layers shared within a repository are counted once. The registry also garbage-collects images that no tag references, including through a multi-platform image. Keep a tag attached to anything you intend to pull later by digest. Storage accounting and garbage collection.

Here is an original retention calculation using those rules. Suppose 30 releases share an identical 8 GB base and each adds a distinct 0.5 GB application layer, measured at the size actually pushed:

Shared base:                 8 GB
30 distinct application layers: 30 x 0.5 GB = 15 GB
Total retained layer storage:   8 + 15 = 23 GB
Naive full-image multiplication: 30 x 8.5 = 255 GB

The 23 GB result assumes the base layers really are identical and every release remains tagged in the same repository. Rebuilding the base differently can invalidate that assumption. Chunk reuse during transfer is also a different measurement from billed retained layer size.

Hugging Face's storage pricing page lists base rates of $12 per TB per month for public repositories and $18 for private repositories, with volume discounts. Included storage and plan eligibility still matter. Estimate incremental usage against your existing allowance before treating either headline rate as your bill.

What to do

Start with a private pilot repository and a single release image. Enable Container Repos, create the destination, then test a writer and a separate reader against it. For CI, choose either a narrowly configured Trusted Publisher or a dedicated user token with the needed scope.

Record the source and destination digests. If your release process verifies signatures, verify the copied artifact through that same process. Keep a release tag on the previous working image and demonstrate a rollback using its recorded digest before considering the migration complete.

Finally, compare two consecutive builds rather than one upload. Record transferred bytes, elapsed time and retained storage for the client you intend to use. A registry migration earns its place when it simplifies credentials or improves the release workflow under your actual build conditions. Having models and containers on one Hub is convenient; proving that the next deployment and the previous release both work is the useful test.