I have a container image (let's call it FOO in this example) in a private docker hub repository that, after authenticating with 'docker login', i'm easily able to pull by calling
docker pull myusername/FOO:1.0
I can pull it, run it locally - works great.
However, when I try to launch a deployment with that image via -
kubectl create deployment footest --image=myusername/FOO:1.0
it fails to pull the image. When I set the image to public, everything works fine though. It's when it's in private mode I can't create a Kubernetes deployment with it.
Any indication on what next steps I should do here to be able to pull this private image?
You have to create a secret which will be storing repo authentication details.
you have to update deployment with
imagePullSecrets:
- name: myregistrykey
for more details you can have a look at official document :https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
example :
create pod using private repo image
apiVersion: v1
kind: Pod
metadata:
name: private-reg
spec:
containers:
- name: private-reg-container
image: <your-private-image>
imagePullSecrets:
- name: regcred
you can create sceret using
kubectl create secret docker-registry regcred --docker-server=<your-registry-server> --docker-username=<your-name> --docker-password=<your-pword> --docker-email=<your-email>
where:
<your-registry-server> is your Private Registry.
<your-name> is your Docker username.
<your-pword> is your Docker password.
<your-email> is your Docker email.