DevOpsInterviewPrep logo
← ☸️ Containers & Kubernetes
Foundational

Docker registry token challenges and repository scopes

Read a registry Bearer challenge, separate the token service from the registry service, and diagnose access for the exact repository operation.

TL;DR: A registry can challenge a request with the token endpoint, service identifier and required repository scope. Successful login identifies a credential; the later operation still needs the appropriate authorization.

What the challenge identifies

A client requesting a private manifest may receive an initial 401 with a WWW-Authenticate header. That response can begin the normal token exchange. Repeated failure after the exchange needs investigation. Distribution's token protocol defines the challenge and scoped authorization flow.

Consider this invented, non-runnable header:

WWW-Authenticate: Bearer realm="https://auth.example.invalid/token",service="images.example.invalid",scope="repository:team/api:pull"

realm identifies the token endpoint. service identifies the intended registry service. scope names the repository and requested action. Preserve all three in a sanitized incident record; omit credentials, authorization headers and returned tokens.

rendering diagram…

Make the comparison specific

Suppose a robot account pulls team/base but cannot publish team/api. Record the two repository names and actions before changing its credential. A successful pull is evidence for that pull only. Adding broad write access would obscure whether the destination name was simply wrong.

ObservationEvidence to collect next
Login succeeds; push is deniedDestination repository, requested action and policy decision
Token endpoint cannot be reachedDNS, TLS and routing to the challenge's realm
Failure began after reverse-proxy migrationAdvertised realm and service versus configured verifier values
Developer laptop succeeds; robot failsEffective identity and repository policy for each client

Authentication logs and registry logs often belong to different components. Correlate timestamps and request identifiers across them. A proxy can rewrite a response or strip an authentication header, so one HTTP status alone does not identify the failing component.

A bounded exercise

Create a paper permission matrix for a fixture identity: pull from team/base, push to team/api, and no access to finance/private. Write the expected outcome for each operation and the evidence that would prove the correct account was used. Add a case where the client targets teams/api by mistake. The repair is the repository reference, not an extra wildcard permission.

Then replace only the advertised token realm with an unreachable fixture hostname. The expected failure moves earlier in the exchange. No repository policy change should be needed to explain that case. This exercise reviews protocol reasoning; it does not test a live authentication server.

For an actual integration test, use an isolated registry and approved fixture accounts. Keep secrets out of verbose HTTP traces and CI artifacts. Test both the allowed operation and a denied neighboring repository before accepting a policy change.

Check your understanding

Why can a client receive a token and still lack push permission? Token issuance and the granted access set are separate evidence. Compare requested actions with the authorization decision; receiving a response from the token service does not prove every requested action was granted.

Connect the permission decision to identity boundaries, then continue with the pull sequence and the registry preparation path.

RELATED CONCEPTS
PRACTICE THIS IN REAL QUESTIONS