Skip to content

build/bake: support Docker Hub OIDC registry identities#265

Merged
crazy-max merged 2 commits into
mainfrom
dockerhub-oidc
Jul 24, 2026
Merged

build/bake: support Docker Hub OIDC registry identities#265
crazy-max merged 2 commits into
mainfrom
dockerhub-oidc

Conversation

@crazy-max

Copy link
Copy Markdown
Member

follow-up docker/login-action#1054

This adds Docker Hub OIDC support to registry identities so build.yml, bake.yml, and verify.yml can authenticate to Docker Hub without passing a Docker Hub token through the reusable workflow boundary.

The registry identity setup workflow now accepts type: dockerhub with a username, connection ID, and optional registry value that defaults to Docker Hub. The build, bake, and verify workflows mint the Docker Hub token inside each job through docker/login-action and pass the resolved registry into the login step.

This keeps Docker Hub OIDC aligned with the existing registry identity model while avoiding token plumbing between jobs. The registry remains configurable instead of being hardcoded, and callers can keep using registry-auths for static credentials alongside keyless registry identities.

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
@crazy-max
crazy-max requested review from thaJeztah and vvoland July 24, 2026 14:00
@crazy-max
crazy-max requested a review from a team as a code owner July 24, 2026 14:00
Comment on lines +890 to +899
-
name: Login to Docker Hub with OIDC
if: ${{ needs.registry-identities.outputs.dockerhub-oidc-enabled == 'true' }}
uses: docker/login-action@abd2ef45e78c5afb21d64d4ca52ee8550d9572c7 # v4.5.1
env:
DOCKERHUB_OIDC_CONNECTIONID: ${{ needs.registry-identities.outputs.dockerhub-oidc-connection-id }}
with:
registry-auth: |
- registry: ${{ needs.registry-identities.outputs.dockerhub-oidc-registry }}
username: ${{ needs.registry-identities.outputs.dockerhub-oidc-username }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My AI frend flagged this:

The pinned docker/login-action requests a 300-second Docker Hub OIDC token unless DOCKERHUB_OIDC_EXPIREIN is set.

This login runs before the full build-and-push step. Docker stores that token as the registry password, so a build lasting more than five minutes can fail when BuildKit requests authorization during the push.

Set DOCKERHUB_OIDC_EXPIREIN: 3600 in the Docker Hub login steps, including the equivalent bake.yml block, or otherwise refresh credentials before registry operations.
The verify and finalize jobs should use the longer lifetime too if they can process many images.

@crazy-max crazy-max Jul 24, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He's wrong, the expire-in doesn't apply to the auth to the registry but the mint token used before authenticating.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see!

@crazy-max
crazy-max merged commit f7225ad into main Jul 24, 2026
221 checks passed
@crazy-max
crazy-max deleted the dockerhub-oidc branch July 24, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants