<p>I'm trying to run my kuberntes app using minikube on ubuntu20.04 and applied a secret to pull a private docker image from docker hub, but it doesn't seem to work correctly.</p>
<blockquote>
<p>Failed to pull image &quot;xxx/node-graphql:latest&quot;: rpc error: code
= Unknown desc = Error response from daemon: pull access denied for xxx/node-graphql, repository does not exist or may require
'docker login': denied: requested access to the resource is denied</p>
</blockquote>
<p>Here's the secret generated by</p>
<pre><code>kubectl create secret generic regcred \                     
    --from-file=.dockerconfigjson=&lt;pathtofile&gt;.docker/config.json \
    --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>And here's the secret yaml file I have created</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: xxx9tRXpNakZCSTBBaFFRPT0iCgkJfQoJfQp9
kind: Secret
metadata:
  name: node-graphql-secret
  uid: xxx-2e18-44eb-9719-xxx
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>Did anyone try to pull a private docker image into Kubernetes using a secret? Any kind of help would be appreciated. Thank you!</p>

DreamBold
<p>I managed to add the secrets config in the following steps.</p>
<p>First, you need to login to docker hub using:</p>
<pre><code>docker login
</code></pre>
<p>Next, you create a k8s secret running:</p>
<pre><code>kubectl create secret generic &lt;your-secret-name&gt;\\n    --from-file=.dockerconfigjson=&lt;pathtoyourdockerconfigfile&gt;.docker/config.json \\n    --type=kubernetes.io/dockerconfigjson
</code></pre>
<p>And then get the secret in yaml format</p>
<pre><code>kubectl get secret -o yaml
</code></pre>
<p>It should look like this:</p>
<pre><code>apiVersion: v1
items:
- apiVersion: v1
  data:
    .dockerconfigjson: xxxewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tl
  kind: Secret
  metadata:
    creationTimestamp: &quot;2022-10-27T23:06:01Z&quot;
    name: &lt;your-secret-name&gt;
    namespace: default
    resourceVersion: &quot;513&quot;
    uid: xxxx-0f12-4beb-be41-xxx
  type: kubernetes.io/dockerconfigjson
kind: List
metadata:
  resourceVersion: &quot;&quot;
</code></pre>
<p>And I have copied the content for the secret in the secret yaml file:</p>
<pre><code>apiVersion: v1
data:
  .dockerconfigjson: xxxewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tlci
kind: Secret
metadata:
  creationTimestamp: &quot;2022-10-27T23:06:01Z&quot;
  name: &lt;your-secret-name&gt;
  namespace: default
  resourceVersion: &quot;513&quot;
  uid: xxx-0f12-4beb-be41-xxx
type: kubernetes.io/dockerconfigjson
</code></pre>
<p>It works! This is a simple approach to using <code>Secret</code> to pull a private docker image for K8s.</p>
<p>As a side note, to apply the secret, run <code>kubectl apply -f secret.yml</code></p>
<p>Hope it helps</p>
