Use it when pulls fail with unauthorized or denied.
Private Registry Authentication
Private registry authentication: clients log in with credentials or tokens; Kubernetes uses imagePullSecrets or node/cloud identity (IRSA, workload identity) to pull from private registries.
1. Error text: unauthorized / denied / not found.
2. kubectl get secret <s> -o jsonpath='{.type}' — dockerconfigjson?
3. Pod/ServiceAccount references the secret?
4. Test: docker login <registry> with the same credentials.
5. Token expiry/rotation.
pod → imagePullSecret/identity → registry auth → pull
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Pull manually with the same credentials on a node. Confirm the Secret is in the same namespace as the Pod. Confirm the service account lists it in imagePullSecrets if the Pod spec does not.
Step 2 Common failures Narrow the fault
A secret in another namespace is not usable. Expired cloud registry tokens cause intermittent failures on new nodes only. A typo or port difference in the registry host means credentials are never sent.
Secrets must be in the same namespace as the pod and of type kubernetes.io/dockerconfigjson. Tokens expire (ECR 12 h). Prefer cloud identities over static passwords.
docker ps -a— containers and exit codesdocker logs <c>— container outputdocker inspect <c>— config, mounts, network, state
ReferenceWhat it is1 section · depth on demand
How it works
The client requests a token from the registry auth endpoint and uses it for manifest and blob requests. Kubernetes passes the pull secret to the kubelet, which uses it when the runtime pulls. Cloud registries often use short-lived tokens refreshed by a credential provider.
ReferenceImportant terms & boundaries3 sections · depth on demand
Credentials per tool
| Tool | How |
|---|---|
| Docker | docker login registry.example.com → ~/.docker/config.json (use a credential helper) |
| Podman | podman login → ${XDG_RUNTIME_DIR}/containers/auth.json |
| Kubernetes | imagePullSecrets (type kubernetes.io/dockerconfigjson) or node/workload identity (ECR, ACR, GAR) |
kubectl create secret docker-registry regcred --docker-server=registry.example.com --docker-username=bot --docker-password=<token>
Documented example, not captured output. Use read-only robot accounts or tokens with expiry.
In depth
Registry authentication follows the Docker registry token flow: the first request returns 401 with a WWW-Authenticate header naming the token service; the client sends credentials there, gets a short-lived bearer token and retries.
Kubernetes: three places a pull credential can come from
| Source | Scope | Notes |
|---|---|---|
imagePullSecrets on the Pod | That Pod | Secret type kubernetes.io/dockerconfigjson, same namespace |
imagePullSecrets on the ServiceAccount | Every Pod using that ServiceAccount | Added automatically at admission |
| Kubelet credential provider / node config | Whole node | Used for cloud registries (ECR, ACR, GAR) with short-lived tokens |
Worked setup
kubectl -n app create secret docker-registry regcred \
--docker-server=registry.example.com --docker-username=ci --docker-password="$TOKEN"
kubectl -n app patch serviceaccount default \
-p '{"imagePullSecrets":[{"name":"regcred"}]}'
kubectl -n app get pod web-0 -o jsonpath='{.spec.imagePullSecrets}'
Reading pull errors
| Event text | Meaning |
|---|---|
401 Unauthorized / authentication required | No credential matched the registry host, or it is wrong |
403 Forbidden | Credential valid, but lacks pull rights on that repository |
manifest unknown | Authenticated fine; the tag or digest does not exist |
The server name in the secret must match the image reference exactly, including the port (registry.example.com:5000).
Common mistakes
- Registry credentials stored in plain text.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.