Can anyone please guide how to pull private images from Kubernetes?

3/29/2020

kubectl create secret docker-registry private-registry-key --docker-username="devopsrecipes" --docker-password="xxxxxx" --docker-email="username@example.com" --docker-server="https://index.docker.io/v1/" secret "private-registry-key" created

This command is used for accessing private docker repos.

As referenced: http://blog.shippable.com/kubernetes-tutorial-how-to-pull-private-docker-image-pod

But, not able to pull the image.

When tried to access ="https://index.docker.io/v1/" It is giving page not found error.

Please guide me.

-- uday kiran
kubernetes

2 Answers

3/29/2020

I Just tried creating the same on my cluster.

kubectl create secret docker-registry private-registry-key --docker-username="xx" --docker-password="xx" --docker-email="xx" --docker-server="https://index.docker.io/v1/"

Output:

secret/private-registry-key created

My Yaml file looks like

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: vaibhavjain882/ubuntubase:latest
    command: ["sleep", "30"]
  imagePullSecrets:
  - name: private-registry-key


NAME          READY   STATUS    RESTARTS   AGE
private-reg   1/1     Running   0          35s

Note: Just verify, if you are passing the correct docker image name. In my case its "vaibhavjain882/ubuntubase:latest"

-- Vaibhav Jain
Source: StackOverflow

3/29/2020

You also need to refer the imagePullSecrets in the pod / deployment spec you create:

apiVersion: v1
kind: Pod
metadata:
  name: private-reg
spec:
  containers:
  - name: private-reg-container
    image: <your-private-image>
  imagePullSecrets:
  - name: private-registry-key

Read more about imagePullSecrets here.

-- Abhishek Jaisingh
Source: StackOverflow