<p>I am trying to connect a folder in windows to a container folder. This is for a .NET app that needs to read files in a folder. In a normal docker container, with docker-compose, the app works without problems, but since this is only one of several different apps that we will have to monitor, we are trying to get kubernetes involved. That is also where we are failing.
As a beginner with kubernetes, I used kompose.exe to convert the compose files to kuberetes style. However, no matter if I use hostPath or persistentVolumeClaim as a flag, I do not get things to work &quot;out of the box&quot;. With hostPath, the path is very incorrect, and with persistentVolumeClaim I get a warning saying volume mount on the host is not supported.
I, therefore, tried to do that part myself but can get it to work with neither persistent volume nor entering mount data in the deployment file directly.
The closest I have come is that I can enter the folder, and I can change to subfolders within, but as soon as I try to run any other command, be it 'ls' or 'cat', I get &quot;Operation not permitted&quot;.
Here is my docker compose file, which works as expected by</p>
<pre><code>version: &quot;3.8&quot;
services:
    test-create-hw-file:
        container_name: &quot;testcreatehwfile&quot;
        image: test-create-hw-file:trygg
        network_mode: &quot;host&quot;
        volumes:
            - /c/temp/testfiles:/app/files
</code></pre>
<p>Running konvert compose on that file:</p>
<pre><code>PS C:\temp&gt; .\kompose.exe convert -f .\docker-compose-tchwf.yml --volumes hostPath -v
DEBU Checking validation of provider: kubernetes
DEBU Checking validation of controller:
DEBU Docker Compose version: 3.8
WARN Service &quot;test-create-hw-file&quot; won't be created because 'ports' is not specified
DEBU Compose file dir: C:\temp
DEBU Target Dir: .
INFO Kubernetes file &quot;test-create-hw-file-deployment.yaml&quot; created
</code></pre>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    kompose.cmd: C:\temp\kompose.exe convert -f .\docker-compose-tchwf.yml --volumes hostPath -v
    kompose.version: 1.26.1 (a9d05d509)
  creationTimestamp: null
  labels:
    io.kompose.service: test-create-hw-file
  name: test-create-hw-file
spec:
  replicas: 1
  selector:
    matchLabels:
      io.kompose.service: test-create-hw-file
  strategy:
    type: Recreate
  template:
    metadata:
      annotations:
        kompose.cmd: C:\temp\kompose.exe convert -f .\docker-compose-tchwf.yml --volumes hostPath -v
        kompose.version: 1.26.1 (a9d05d509)
      creationTimestamp: null
      labels:
        io.kompose.service: test-create-hw-file
    spec:
      containers:
        - image: test-create-hw-file:trygg
          name: testcreatehwfile
          resources: {}
          volumeMounts:
            - mountPath: /app/files
              name: test-create-hw-file-hostpath0
      restartPolicy: Always
      volumes:
        - hostPath:
            path: C:\temp\c\temp\testfiles
          name: test-create-hw-file-hostpath0
status: {}
</code></pre>
<p>Running kubectl apply on that file just gives the infamous error &quot;Error: Error response from daemon: invalid mode: /app/files&quot;, which means, as far as I can understand, not that the &quot;/app/files&quot; is wrong, but the format of the supposedly connected folder is incorrect. This is the quite weird <code>C:\temp\c\temp\testfiles</code> row. After googling and reading a lot, I have two ways of changing that, to either <code>/c/temp/testfiles</code> or <code>/host_mnt/c/temp/testfiles</code>. Both end up in the same &quot;Operation not permitted&quot;. I am checking this via going into the CLI on the container in the docker desktop.</p>
<p>The image from the test is just an app that does nothing right now other than wait for five minutes to not quit before I can check the folder.
I am logged on to the shell as root, and I have this row for the folder when doing 'ls -lA':</p>
<pre><code>drwxrwxrwx 1 root root      0 Feb  7 12:04 files
</code></pre>
<p>Also, the <code>docker-user</code> has full access to the <code>c:\temp\testfiles</code> folder.</p>
<p><strong>Some version data:</strong></p>
<pre><code>Docker version 20.10.12, build e91ed57

Kubectl version
Client Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.5&quot;, GitCommit:&quot;5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-12-16T08:38:33Z&quot;, GoVersion:&quot;go1.16.12&quot;, Compiler:&quot;gc&quot;, Platform:&quot;windows/amd64&quot;}
Server Version: version.Info{Major:&quot;1&quot;, Minor:&quot;22&quot;, GitVersion:&quot;v1.22.5&quot;, GitCommit:&quot;5c99e2ac2ff9a3c549d9ca665e7bc05a3e18f07e&quot;, GitTreeState:&quot;clean&quot;, BuildDate:&quot;2021-12-16T08:32:32Z&quot;, GoVersion:&quot;go1.16.12&quot;, Compiler:&quot;gc&quot;, Platform:&quot;linux/amd64&quot;}

Kompose version
1.26.1 (a9d05d509)

Host OS: Windows 10, 21H2
</code></pre>
<p>//Trygg</p>

<p>Glad that my initial comment solved your issue. I would like to expand my thoughts a little in a form of an official answer.</p>
<p>To mount volumes using Kubernetes on Docker Desktop for Windows the path will be:</p>
<pre class="lang-yaml prettyprint-override"><code>/run/desktop/mnt/host/c/PATH/TO/FILE
</code></pre>
<p>Unfortunately there is no official documentation but <a href="https://github.com/docker/for-win/issues/5325#issuecomment-567594291" rel="noreferrer">here</a> is a good comment with explanation that this is related to Docker Daemon:</p>
<blockquote>
<p>/mnt/wsl is actually the mount point for the cross-distro mounts tmpfs<br />
Docker Daemon mounts it in its /run/desktop/mnt/host/wsl directory</p>
</blockquote>
