title: Kubernetes pull from local registry not working, how to fix that?
body: <p>I followed this <a href="https://stackoverflow.com/questions/51893120/kubernetes-pull-from-insecure-docker-registry">link</a> and created a secret as below.</p>
  <pre><code>kubectl create secret docker-registry regsec --docker-server=192.168.56.106:5000 --docker-username=osboxes --docker-password=osboxes.org --insecure-skip-tls-verify=true
  </code></pre>
  <p>And the deployment as below.</p>
  <pre><code>kubectl create deploy nginx1 --image 192.168.56.106:5000/todoapp:1.0
  </code></pre>
  <p>And edited it using</p>
  <pre><code>kubectl edit deploy nginx1
  </code></pre>
  <p>And added imagePullSecrets to it</p>
  <pre><code># Please edit the object below. Lines beginning with a '#' will be ignored,
  # and an empty file will abort the edit. If an error occurs while saving this file will be
  # reopened with the relevant failures.
  #
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    annotations:
      deployment.kubernetes.io/revision: &quot;2&quot;
    creationTimestamp: &quot;2021-07-21T10:23:23Z&quot;
    generation: 2
    labels:
      app: nginx1
    name: nginx1
    namespace: default
    resourceVersion: &quot;6872&quot;
    uid: 0b6917f0-10ac-4206-82a8-c49ae8ffa2b3
  spec:
    progressDeadlineSeconds: 600
    replicas: 1
    revisionHistoryLimit: 10
    selector:
      matchLabels:
        app: nginx1
    strategy:
      rollingUpdate:
        maxSurge: 25%
        maxUnavailable: 25%
      type: RollingUpdate
    template:
      metadata:
        creationTimestamp: null
        labels:
          app: nginx1
      spec:
        containers:
        - image: 192.168.56.106:5000/todoapp:1.0
          imagePullPolicy: IfNotPresent
          name: todoapp
          resources: {}
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
        dnsPolicy: ClusterFirst
        imagePullSecrets:
        - name: regsec
        restartPolicy: Always
        schedulerName: default-scheduler
        securityContext: {}
        terminationGracePeriodSeconds: 30
  status:
    conditions:
    - lastTransitionTime: &quot;2021-07-21T10:23:23Z&quot;
      lastUpdateTime: &quot;2021-07-21T10:23:23Z&quot;
      message: Deployment does not have minimum availability.
      reason: MinimumReplicasUnavailable
      status: &quot;False&quot;
      type: Available
    - lastTransitionTime: &quot;2021-07-21T10:23:23Z&quot;
      lastUpdateTime: &quot;2021-07-21T10:28:36Z&quot;
      message: ReplicaSet &quot;nginx1-75df7fd466&quot; is progressing.
      reason: ReplicaSetUpdated
      status: &quot;True&quot;
      type: Progressing
    observedGeneration: 2
    replicas: 2
    unavailableReplicas: 2
    updatedReplicas: 1
  </code></pre>
  <p>But still getting below error.</p>
  <pre><code>osboxes@osboxes:~/Desktop$ kubectl get pods
      NAME                      READY   STATUS             RESTARTS   AGE
      nginx-6799fc88d8-vvzjf    1/1     Running            0          19m
      nginx1-65d848d94f-dd4ck   0/1     ImagePullBackOff   0          12m
      nginx1-75df7fd466-kn5mf   0/1     ImagePullBackOff   0          6m50s
  
  osboxes@osboxes:~/Desktop$ kubectl describe pod nginx1-75df7fd466-kn5mf
  Name:         nginx1-75df7fd466-kn5mf
  Namespace:    default
  Priority:     0
  Node:         samples-control-plane/172.19.0.3
  Start Time:   Wed, 21 Jul 2021 06:28:36 -0400
  Labels:       app=nginx1
                pod-template-hash=75df7fd466
  Annotations:  &lt;none&gt;
  Status:       Pending
  IP:           10.244.0.8
  IPs:
    IP:           10.244.0.8
  Controlled By:  ReplicaSet/nginx1-75df7fd466
  Containers:
    todoapp:
      Container ID:
      Image:          192.168.56.106:5000/todoapp:1.0
      Image ID:
      Port:           &lt;none&gt;
      Host Port:      &lt;none&gt;
      State:          Waiting
        Reason:       ImagePullBackOff
      Ready:          False
      Restart Count:  0
      Environment:    &lt;none&gt;
      Mounts:
        /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-88clq (ro)
  Conditions:
  
    Type              Status
    Initialized       True
    Ready             False
    ContainersReady   False
    PodScheduled      True
  Volumes:
    kube-api-access-88clq:
      Type:                    Projected (a volume that contains injected data from multiple sources)
      TokenExpirationSeconds:  3607
      ConfigMapName:           kube-root-ca.crt
      ConfigMapOptional:       &lt;nil&gt;
      DownwardAPI:             true
  QoS Class:                   BestEffort
  Node-Selectors:              &lt;none&gt;
  Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                               node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
  Events:
    Type     Reason     Age                From               Message
    ----     ------     ----               ----               -------
    Normal   Scheduled  73s                default-scheduler  Successfully assigned default/nginx1-75df7fd466-kn5mf to samples-control-plane
    Normal   Pulling    33s (x3 over 73s)  kubelet            Pulling image &quot;192.168.56.106:5000/todoapp:1.0&quot;
    Warning  Failed     33s (x3 over 73s)  kubelet            Failed to pull image &quot;192.168.56.106:5000/todoapp:1.0&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;192.168.56.106:5000/todoapp:1.0&quot;: failed to resolve reference &quot;192.168.56.106:5000/todoapp:1.0&quot;: failed to do request: Head &quot;https://192.168.56.106:5000/v2/todoapp/manifests/1.0&quot;: http: server gave HTTP response to HTTPS client
    Warning  Failed     33s (x3 over 73s)  kubelet            Error: ErrImagePull
    Normal   BackOff    6s (x4 over 72s)   kubelet            Back-off pulling image &quot;192.168.56.106:5000/todoapp:1.0&quot;
    Warning  Failed     6s (x4 over 72s)   kubelet            Error: ImagePullBackOff
  </code></pre>
  <p>kubectl version</p>
  <pre><code>Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;21&quot;, GitVersion:&quot;v1.21.1&quot;, GitCommit:&quot;5e58841cce77d4bc13713ad2b91fa0d961e69192&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-05-13T02:40:46Z&quot;, GoVersion:&quot;go1.16.3&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
  Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;21&quot;, GitVersion:&quot;v1.21.1&quot;, GitCommit:&quot;5e58841cce77d4bc13713ad2b91fa0d961e69192&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-05-21T23:01:33Z&quot;, GoVersion:&quot;go1.16.4&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}
  </code></pre>
  <p>Adding docker insecure registry is not useful as the container runtime is not docker now.It is containerd.</p>
  <p>/etc/default/docker.json</p>
  <p>And for reference, I have setup the local container on a virtualbox VM and connecting to kubernetes on the same network using Host-only network ip address.</p>
  <p>The setup of local registry is created using the steps mentioned in <a href="https://www.exoscale.com/syslog/setup-private-docker-registry/" rel="nofollow noreferrer">link</a>.</p>
  <p>And the kubernetes was setup using <a href="https://linuxdiaryblog.blogspot.com/2021/07/deploy-kubernetes-inside-docker-using.html" rel="nofollow noreferrer">kind</a>.</p>