<p>In kubernetes on windows docker desktop when I try to mount an empty directory I get the following error:</p>

<pre><code>error: error when retrieving current configuration of:
Resource: "/v1, Resource=pods", GroupVersionKind: "/v1, Kind=Pod"
Name: "", Namespace: "default"
Object: &amp;{map["apiVersion":"v1" "kind":"Pod" "metadata":map["annotations":map["kubectl.kubernetes.io/last-applied-configuration":""] "namespace":"default"] "spec":map["containers":[map["image":"nginx:alpine" "name":"nginx" "volumeMounts":[map["mountPath":"/usr/share/nginx/html" "name":"html" "readOnly":%!q(bool=true)]]] map["args":["while true; do date &gt;&gt; /html/index.html; sleep 10; done"] "command":["/bin/sh" "-c"] "image":"alpine" "name":"html-updater" "volumeMounts":[map["mountPath":"/html" "name":"html"]]]] "volumes":[map["emptyDir":map[] "name":"html"]]]]}
from server for: "nginx-alpine-emptyDir.pod.yml": resource name may not be empty
</code></pre>

<p>The error message seems a bit unclear and I cannot find what's going on.
My yaml configuration is the following:</p>

<pre><code>apiVersion: v1
kind: Pod
spec:
  volumes:
    - name: html
      emptyDir: {}
  containers:
    - name: nginx
      image: nginx:alpine
      volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
          readOnly: true
    - name: html-updater
      image: alpine
      command: ["/bin/sh", "-c"]
      args:
        - while true; do date &gt;&gt; /html/index.html; sleep 10; done
      volumeMounts:
        - name: html
          mountPath: /html 

</code></pre>

Victor Timofei
<p>Forgot to add metadata name</p>

<pre><code>metadata:
  name: empty-dir-test
</code></pre>

<p>Code after change is:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: empty-dir-test
spec:
  volumes:
    - name: html
      emptyDir: {}
  containers:
    - name: nginx
      image: nginx:alpine
      volumeMounts:
        - name: html
          mountPath: /usr/share/nginx/html
          readOnly: true
    - name: html-updater
      image: alpine
      command: ["/bin/sh", "-c"]
      args:
        - while true; do date &gt;&gt; /html/index.html; sleep 10; done
      volumeMounts:
        - name: html
          mountPath: /html 
</code></pre>
