<p>I have a local image that runs fine this way:
<code>docker run -p 8080:8080 -v C:\Users\moritz\Downloads\1\imageService\examples1:/images -v C:\Users\moritz\entwicklung\projekte\imageCluster\logs:/logs imageservice</code></p>
<p>Now i want this to run as Kubernetes (using built in from Docker-for-Windows v1.19.7) deployment:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: image-service
spec:
  selector:
    matchLabels:
      app: image-service
  template:
    metadata:
      labels:
        app: image-service
    spec:
      containers:
      - name: image-service
        image: &quot;imageservice&quot;
        resources:
          limits:
            cpu: &quot;0.9&quot;
            memory: &quot;1Gi&quot;
        ports:
        - name: http
          containerPort: 8080
        volumeMounts:
          - mountPath: /images
            name: image-volume
          - mountPath: /logs
            name: log-volume  
      volumes:
        - name: image-volume
          hostPath:
            path: &quot;c:\\Users\\moritz\\Downloads\\1\\imageService\\examples1&quot;
            type: Directory
        - name: log-volume
          hostPath:
            path: /mnt/c/Users/moritz/entwicklung/projekte/imageCluster/logs
            type: Directory
</code></pre>
<p>As you see i tried different ways to set up my host path on windows machine but i always get:</p>
<pre><code>  Warning  FailedMount  0s (x4 over 4s)  kubelet            MountVolume.SetUp failed for volume &quot;log-volume&quot; : hostPath type check failed: /mnt/c/Users/moritz/entwicklung/projekte/imageCluster/logs is not a directory
  Warning  FailedMount  0s (x4 over 4s)  kubelet            MountVolume.SetUp failed for volume &quot;image-volume&quot; : hostPath type check failed: c:\Users\moritz\Downloads\1\imageService\examples1 is not a directory 
</code></pre>
<p>I also tried other variants (for both):</p>
<ul>
<li>C:\Users\moritz\entwicklung\projekte\imageCluster\logs</li>
<li>C:/Users/moritz/entwicklung/projekte/imageCluster/logs</li>
</ul>
<p>So how to correctly setup these windows host path. (The next step would be to set them as environment variable.)</p>
<p><strong>Little update:</strong></p>
<p>removing <code>type: Directory</code> helps to <strong>get rid of the error</strong> and pod is starting but the mounts are not working. If i &quot;look&quot; into container in <code>/images</code> i don't see the images i have on my host and i don't see any logs in log mount while in container /logs contains the expected files.</p>
<p>in meantime i also tried (no avail)</p>
<ul>
<li>/host_mnt/c/...</li>
<li>/C/Users/...</li>
<li>//C/Users/...</li>
</ul>

dermoritz
<p>As mentioned <a href="https://stackoverflow.com/questions/62812948/volume-mounts-not-working-kubernetes-and-wsl-2-and-docker/63524931#63524931">here</a>, you can use below hostPath to make it work on wsl2.</p>
<pre><code>// C:\someDir\volumeDir
hostPath:
  path: /run/desktop/mnt/host/c/someDir/volumeDir
  type: DirectoryOrCreate
</code></pre>
<p>There is also an example you can use.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: test-localpc
spec:
  containers:
  - name: test-webserver
    image: ubuntu:latest
    command: [&quot;/bin/sh&quot;]
    args: [&quot;-c&quot;, &quot;apt-get update &amp;&amp; apt-get install curl -y &amp;&amp; sleep 600&quot;]
    volumeMounts:
    - mountPath: /run/desktop/mnt/host/c/aaa
      name: mydir
    - mountPath: /run/desktop/mnt/host/c/aaa/1.txt
      name: myfile
  volumes:
  - name: mydir
    hostPath:
      # Ensure the file directory is created.
      path: /run/desktop/mnt/host/c/aaa
      type: DirectoryOrCreate
  - name: myfile
    hostPath:
      path: /run/desktop/mnt/host/c/aaa/1.txt
      type: FileOrCreate
</code></pre>
