<p>I'm trying to use <code>Kubernetes</code> with <code>Docker</code>. My image runs with Docker. I have one master-node and two worker-nodes. I also created a local registry like this <code>$ docker run -d -p 5000:5000 --restart=always --name registry registry:2</code> and pushed my image into it. Everything worked fine so far.</p>

<p>I added <code>{ "insecure-registries":["xxx.xxx.xxx.xxx:5000"] }</code> to the <code>daemon.json</code> file at <code>/etc/docker</code>. And I also changed the content of the <code>docker-file</code> at <code>/etc/default/</code>to <code>DOCKER_OPTS="--config-file=/etc/docker/daemon.json"</code>. I made the changes on all nodes and I restarted the docker daemon afterwards.</p>

<p>I am able to pull my image from every node with the following command: </p>

<p><code>sudo docker pull xxx.xxx.xxx.xxx:5000/helloworldimage</code></p>

<p>I try to create my container from the master node with the command bellow:</p>

<p><code>sudo kubectl run test --image xxx.xxx.xxx.xxx:5000/helloworldimage</code></p>

<p>Than I get the following error:</p>

<pre><code>Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  &lt;unknown&gt;          default-scheduler  Successfully assigned default/test-775f99f57-m9r4b to rpi-2
  Normal   BackOff    18s (x2 over 44s)  kubelet, rpi-2     Back-off pulling image "xxx.xxx.xxx.xxx:5000/helloworldimage"
  Warning  Failed     18s (x2 over 44s)  kubelet, rpi-2     Error: ImagePullBackOff
  Normal   Pulling    3s (x3 over 45s)   kubelet, rpi-2     Pulling image "xxx.xxx.xxx.xxx:5000/helloworldimage"
  Warning  Failed     3s (x3 over 45s)   kubelet, rpi-2     Failed to pull image "xxx.xxx.xxx.xxx:5000/helloworldimage": rpc error: code = Unknown desc = failed to pull and unpack image "xxx.xxx.xxx.xxx:5000/helloworldimage:latest": failed to resolve reference "xxx.xxx.xxx.xxx:5000/helloworldimage:latest": failed to do request: Head https://xxx.xxx.xxx.xxx:5000/v2/helloworldimage/manifests/latest: http: server gave HTTP response to HTTPS client
  Warning  Failed     3s (x3 over 45s)   kubelet, rpi-2     Error: ErrImagePull
</code></pre>

<p>This is the <code>docker</code> version I use:</p>

<pre><code>Client: Docker Engine - Community
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        633a0ea
 Built:             Wed Nov 13 07:37:22 2019
 OS/Arch:           linux/arm
 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:       633a0ea
  Built:            Wed Nov 13 07:31:17 2019
  OS/Arch:          linux/arm
  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>This is the <code>Kubernetes</code> version I use:</p>

<pre><code>Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0+k3s.1", GitCommit:"0f644650f5d8e9f091629f860b342f221c46f6d7", GitTreeState:"clean", BuildDate:"2020-01-06T23:20:30Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/arm"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0+k3s.1", GitCommit:"0f644650f5d8e9f091629f860b342f221c46f6d7", GitTreeState:"clean", BuildDate:"2020-01-06T23:20:30Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/arm"}```
</code></pre>

<p>It appears that in some situations solution described <a href="https://github.com/distribution/distribution/issues/1874#issuecomment-468101614" rel="nofollow noreferrer">here</a> solved the problem:</p>
<ol>
<li><code>sudo systemctl edit docker</code></li>
<li>Add below lines:</li>
</ol>
<ul>
<li><code>[Service]</code></li>
<li><code>ExecStart=/usr/bin/dockerd -H fd:// --insecure-registry registry:5000</code></li>
</ul>
<ol start="3">
<li><code>sudo systemctl daemon-reload</code></li>
<li><code>systemctl restart docker</code></li>
<li><code>systemctl status docker</code></li>
</ol>
