<p>I am running docker for desktop with kubernetes enabled.  I am using Windows containers (but have also been running Linux containers - I switched modes to Windows).  Also, kubernetes is running, but has been using Linux, so I guess the single node in the cluster is using the Linux engine, even though I have switched Docker to use Windows containers.  It appears that the local kubernetes cluster is not able to load the Windows image, even though docker is running in Windows container mode.</p>

<p>I am trying to solve the following error: </p>

<p><strong><code>Failed to pull image "iis-site": rpc error: code = Unknown desc = Error response from daemon: pull access denied for iis-site, repository does not exist or may require 'docker login'</code></strong></p>

<h1><strong>Steps to reproduce</strong></h1>

<p>I build a docker image as follows:</p>

<pre><code>FROM microsoft/iis

RUN powershell -NoProfile -Command Remove-Item -Recurse C:\inetpub\wwwroot\*

WORKDIR /inetpub/wwwroot

COPY content/ .
</code></pre>

<p>I have a directory structure like this: </p>

<pre><code>D:\TEMP\IIS
│   Dockerfile
│
└───content
        index.html
</code></pre>

<p>index.html looks like this: </p>

<pre><code>&lt;html&gt;
    &lt;body&gt;
    Hello World!
    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>I run up the container as follows:</p>

<pre><code>docker build -t iis-site .
</code></pre>

<p>I can navigate to <a href="http://localhost:8000/" rel="nofollow noreferrer">http://localhost:8000/</a> and I can see my website! (SUCCESS)</p>

<h1><strong>See it in Kubernetes</strong></h1>

<p>But now I want to see it running in kubernetes (local cluster). </p>

<p>I do </p>

<pre><code>kubectl apply -f D:\Temp\windows-deployment.yaml
</code></pre>

<p><strong>D:\Temp\windows-deployment.yaml</strong></p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: iis-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: iis
    spec:
      containers:
      - name: iis
        image: iis-site
        ports:
        - containerPort: 80
</code></pre>

<p>Now id do:</p>

<p>kubectl get pods</p>

<pre><code>NAME                                  READY     STATUS             RESTARTS   AGE
iis-deployment-5768b4fb85-pfxjk       0/1       ImagePullBackOff   0          18m
sql-deployment-659d64d464-rss5c       1/1       Running            18         40d
streact-deployment-567cf9db9b-g5vkb   1/1       Running            18         39d
web-deployment-669595758-7zcdx        1/1       Running            45         39d
</code></pre>

<p>Now I do  </p>

<pre><code>kubectl describe pod iis-deployment-5768b4fb85-pfxjk
</code></pre>

<p><strong><code>Failed to pull image "iis-site": rpc error: code = Unknown desc = Error response from daemon: pull access denied for iis-site, repository does not exist or may require 'docker login'</code></strong></p>

<h1>Additional info</h1>

<pre><code>kubectl describe node docker-for-desktop

Name:               docker-for-desktop
Roles:              master
Labels:             beta.kubernetes.io/arch=amd64
                    beta.kubernetes.io/os=linux
                    kubernetes.io/hostname=docker-for-desktop
                    node-role.kubernetes.io/master=
Annotations:        node.alpha.kubernetes.io/ttl=0
                    volumes.kubernetes.io/controller-managed-attach-detach=true
CreationTimestamp:  Fri, 11 Jan 2019 10:14:26 +0000
Taints:             &lt;none&gt;
Unschedulable:      false
Conditions:
  Type             Status  LastHeartbeatTime                 LastTransitionTime                Reason                       Message
  ----             ------  -----------------                 ------------------                ------                       -------
  OutOfDisk        False   Wed, 20 Feb 2019 16:32:37 +0000   Wed, 20 Feb 2019 10:06:38 +0000   KubeletHasSufficientDisk     kubelet has sufficient disk space available
  MemoryPressure   False   Wed, 20 Feb 2019 16:32:37 +0000   Wed, 20 Feb 2019 10:06:38 +0000   KubeletHasSufficientMemory   kubelet has sufficient memory available
  DiskPressure     False   Wed, 20 Feb 2019 16:32:37 +0000   Wed, 20 Feb 2019 10:06:38 +0000   KubeletHasNoDiskPressure     kubelet has no disk pressure
  PIDPressure      False   Wed, 20 Feb 2019 16:32:37 +0000   Fri, 11 Jan 2019 10:14:13 +0000   KubeletHasSufficientPID      kubelet has sufficient PID available
  Ready            True    Wed, 20 Feb 2019 16:32:37 +0000   Wed, 20 Feb 2019 10:06:38 +0000   KubeletReady                 kubelet is posting ready status
Addresses:
  InternalIP:  192.168.65.3
  Hostname:    docker-for-desktop
Capacity:
 cpu:                2
 ephemeral-storage:  61664044Ki
 hugepages-2Mi:      0
 memory:             2540888Ki
 pods:               110
Allocatable:
 cpu:                2
 ephemeral-storage:  56829582857
 hugepages-2Mi:      0
 memory:             2438488Ki
 pods:               110
System Info:
 Machine ID:                 
 System UUID:                8776A14E-A225-4134-838E-B50A6ECAB276
 Boot ID:                    5a836f34-51a4-4adf-a32d-218a5df09b3c
 Kernel Version:             4.9.125-linuxkit
 OS Image:                   Docker for Windows
 Operating System:           linux
 Architecture:               amd64
 Container Runtime Version:  docker://18.9.2
 Kubelet Version:            v1.10.11
 Kube-Proxy Version:         v1.10.11
ExternalID:                  docker-for-desktop
Non-terminated Pods:         (12 in total)
  Namespace                  Name                                          CPU Requests  CPU Limits  Memory Requests  Memory Limits
  ---------                  ----                                          ------------  ----------  ---------------  -------------
  default                    iis-deployment-5768b4fb85-pfxjk               0 (0%)        0 (0%)      0 (0%)           0 (0%)
  default                    sql-deployment-659d64d464-rss5c               0 (0%)        0 (0%)      0 (0%)           0 (0%)
  default                    streact-deployment-567cf9db9b-g5vkb           0 (0%)        0 (0%)      0 (0%)           0 (0%)
  default                    web-deployment-669595758-7zcdx                0 (0%)        0 (0%)      0 (0%)           0 (0%)
  docker                     compose-74649b4db6-rm9zc                      0 (0%)        0 (0%)      0 (0%)           0 (0%)
  docker                     compose-api-fb7b8f78f-drllk                   0 (0%)        0 (0%)      0 (0%)           0 (0%)
  kube-system                etcd-docker-for-desktop                       0 (0%)        0 (0%)      0 (0%)           0 (0%)
  kube-system                kube-apiserver-docker-for-desktop             250m (12%)    0 (0%)      0 (0%)           0 (0%)
  kube-system                kube-controller-manager-docker-for-desktop    200m (10%)    0 (0%)      0 (0%)           0 (0%)
  kube-system                kube-dns-86f4d74b45-h2p5q                     260m (13%)    0 (0%)      110Mi (4%)       170Mi (7%)
  kube-system                kube-proxy-p8vj7                              0 (0%)        0 (0%)      0 (0%)           0 (0%)
  kube-system                kube-scheduler-docker-for-desktop             100m (5%)     0 (0%)      0 (0%)           0 (0%)
Allocated resources:
  (Total limits may be over 100 percent, i.e., overcommitted.)
  CPU Requests  CPU Limits  Memory Requests  Memory Limits
  ------------  ----------  ---------------  -------------
  810m (40%)    0 (0%)      110Mi (4%)       170Mi (7%)
Events:         &lt;none&gt;
</code></pre>

<p><strong>Note:</strong> 
The above output indicates the following: </p>

<pre><code> Operating System:           linux
</code></pre>

<p>So it appears that even though the docker engine is running Windows containers, the local Kubernetes cluster (control plane) is running Linux.  </p>

<p>I would greatly appreciate any ideas on how to fix the above error i.e. <strong>pull access denied</strong> so that I can run a local Kubernetes cluster on Windows 10 with <strong>Windows</strong> containers.</p>

<p>The error you are seeing is not related to whether it can run or cannot run Windows containers, it's because it's not able to pull the image. It doesn't look like you pushed the image to <a href="https://hub.docker.com/" rel="nofollow noreferrer">docker hub</a>.  After you build it you need to run:</p>

<pre><code>docker tag -t &lt;yourdockerhubuser&gt;/iis iis
docker push &lt;yourdockerhubuser&gt;/iis
</code></pre>

<p>You will need to set up your docker hub credentials as an <a href="https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/" rel="nofollow noreferrer">ImagePullSecrets</a> on your deployment. Then on you K8s deployment:</p>

<pre><code>apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: iis-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: iis
    spec:
      containers:
      - name: &lt;yourdockerhubuser&gt;/iis
        image: iis-site
        ports:
        - containerPort: 80
     imagePullSecrets:
     - name: &lt;your-docker-hub-user-secret&gt;
</code></pre>

<p>Ok, this container will not run because you have Linux on your node, so you need to have a Windows node and for that, you will have <a href="https://kubernetes.io/docs/getting-started-guides/windows/" rel="nofollow noreferrer">set up the kubelet</a> on your Windows machine. (I believe Docker for Windows doesn't support a Windows kubelet, and just a Linux kubelet running in VM).</p>
