'Sharing directory from Windows host to Kubernetes container (using Docker Desktop)

I would like to share a directory from my Windows host to my Kubernetes container, achieving the same what I used to have in docker-compose:

        volumes:
            - ./data:/mnt/data

I tried with hostPath the following way:

  volumes:
  - name: data-vol
    hostPath:
      path: ./data
      type: Directory

It failed with "MountVolume.SetUp failed for volume "data-vol" : hostPath type check failed: ./data is not a directory"

I tried with different path formats (e.g: /C/data or /host_mnt/c/data) but no success. Any idea how to overcome this?



Solution 1:[1]

Can you try to use absolute path instead relative:

FROM: path: ./data type: Directory

TO: path: /my/absolute/path/data type: Directory

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 DaniVendetta