<p>I am trying to pull images from my docker-hub repo. I followed the documentation found here: <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/</a></p>
<p>However, after typing in the command:</p>
<blockquote>
<p>kubectl create secret generic docker-credentials --from-file=/my/local/path/to/.docker/config.json --type=kubernetes.io/dockerconfigjson</p>
</blockquote>
<p>I get the following error:</p>
<blockquote>
<p>The Secret &quot;docker-credentials&quot; is invalid: data[.dockerconfigjson]:
Required value</p>
</blockquote>
<p>I tried deleting the config.json and re-logging in but with no change in behaviour.</p>
<p>docker version prints:</p>
<pre><code>Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea838
 Built:             Wed Nov 13 07:29:52 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.12
  Git commit:       633a0ea838
  Built:            Wed Nov 13 07:28:22 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
</code></pre>
<p>kubectl version prints:</p>
<pre><code>Client Version: version.Info{
  Major:&quot;1&quot;,
  Minor:&quot;17&quot;,
  GitVersion:&quot;v1.17.2&quot;,
  GitCommit:&quot;59603c6e503c87169aea6106f57b9f242f64df89&quot;,
  GitTreeState:&quot;clean&quot;,
  BuildDate:&quot;2020-01-18T23:30:10Z&quot;,
  GoVersion:&quot;go1.13.5&quot;,
  Compiler:&quot;gc&quot;,
  Platform:&quot;linux/amd64&quot;
}
Server Version: version.Info{
  Major:&quot;1&quot;,
  Minor:&quot;15&quot;,
  GitVersion:&quot;v1.15.2&quot;,
  GitCommit:&quot;f6278300bebbb750328ac16ee6dd3aa7d3549568&quot;,
  GitTreeState:&quot;clean&quot;,
  BuildDate:&quot;2019-08-05T09:15:22Z&quot;,
  GoVersion:&quot;go1.12.5&quot;,
  Compiler:&quot;gc&quot;,
  Platform:&quot;linux/amd64&quot;
}
</code></pre>
<p>the config.json looks like this:</p>
<pre><code>{
    &quot;auths&quot;: {
        &quot;https://index.docker.io/v1/&quot;: {
            &quot;auth&quot;: &quot;secret-stuff&quot;
        }
    },
    &quot;HttpHeaders&quot;: {
        &quot;User-Agent&quot;: &quot;Docker-Client/19.03.5 (linux)&quot;
    }
}
</code></pre>
<p>For the moment I can enter the credentials manually but I'd like to understand what's going wrong.</p>

Marcus Ruddick
<p>I ran into the same issue with <code>kubectl create secret generic --type=kubernetes.io/dockerconfigjson</code> (&quot;<em>The Secret &quot;xxx&quot; is invalid: data[.dockerconfigjson]: Required value</em>&quot;) and it was because of a mistake in the command line, which I think Marcus's command has too.</p>
<p>I had:</p>
<p><code>--from-file=/run/user/xxxx/containers/auth.json</code></p>
<p>It was supposed to be:</p>
<p><code>--from-file=.dockerconfigjson=/run/user/xxxx/containers/auth.json</code></p>
<p>I mis-interpreted the --from-file option as taking a file path, but it takes a key=value, which I guess in this case is supposed to be the key &quot;.dockerconfigjson&quot;.</p>
<p>The answer by Crou hints at --from-file as the culprit, but I thought I would add an answer to spell out what's missing.  (And I think the point about the file <code>type</code> being missing was misleading, because the --type option is there in the command, that's why I skipped over that answer originally when looking at this question for help.)</p>
<p>Note that I got a hint of what was wrong by running kubectl in verbose mode (--v=N, see <a href="https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-output-verbosity-and-debugging" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/kubectl/cheatsheet/#kubectl-output-verbosity-and-debugging</a>), which showed kubectl telling the API server the structure of the Secret resource, and the structure didn't say &quot;.dockerconfigjson&quot; like I expected from the Secret YAML examples in the Kubernetes docs.</p>
