Image Pullback Issues
Log in to Docker
docker login
When prompted, enter your Docker username and password.
The login process creates or updates a config.json
file that holds an authorization token.
View the config.json
file:
cat ~/.docker/config.json
The output contains a section similar to this:
Create a Secret based on existing Docker credentials
A Kubernetes cluster uses the Secret of kubernetes.io/dockerconfigjson
type to authenticate with a container registry to pull a private image.
If you already ran docker login
, you can copy that credential into Kubernetes:
Replace the path in the below command
kubectl create secret generic regcred --from-file=.dockerconfigjson=/home/hcmlxadmin/.docker/config.json --type=kubernetes.io/dockerconfigjson
Create a Pod Deployment
nano testpod.yml
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: nginx
imagePullSecrets:
- name: regcred
Save the file
kubectl apply -f testpod.yml
kubectl get pod private-reg
Last updated
Was this helpful?