Skip to main content

Container Registry Secrets

A Kubernetes Secret stores a small amount of sensitive data - such as a password, token, or key - separately from your application code or container image. To let pods pull images from a private container registry, create a Docker registry secret and reference it from your pod specification.

This keeps registry credentials out of your images and manifests.


Create a Docker Registry Secret

Create a secret with your registry credentials:

kubectl create secret docker-registry name-secrets \
--docker-username=username \
--docker-password=pass1234 \
--docker-server=registry.e2enetworks.net

Replace name-secrets with your secret's name, and use your own registry username, password, and server.

Use the Secret in a Pod

Reference the secret with imagePullSecrets so the pod can pull from the private registry:

cat > private-reg-pod-example.yaml << EOF
apiVersion: v1
kind: Pod
metadata:
name: node-hello
spec:
containers:
- name: node-hello-container
image: registry.e2enetworks.net/your-repo/your-image@sha256:<digest>
imagePullSecrets:
- name: name-secrets
EOF

kubectl apply -f private-reg-pod-example.yaml

The pod uses name-secrets to authenticate to the registry when pulling the image.


ResourceUse it for
Connect to a Clusterkubeconfig and kubectl setup.
Object StorageStore and pull artifacts from object storage.
Kubernetes GuidesMore in-cluster how-tos.
Last updated on June 24, 2026.