MountVolume.SetUp failed for volume "mongo" : hostPath type check failed: /mongo/data is not a directory MountVolume.SetUp failed for volume "mongo" : hostPath type check failed: /mongo/data is not a directory docker docker

MountVolume.SetUp failed for volume "mongo" : hostPath type check failed: /mongo/data is not a directory


Changing type: Directory to type: DirectoryOrCreate works for me.


If by any chance you are using minikube, then don't forget that minikube itself is a container. So hostPath points to a path in that container, not to a path on your host machine. You have to mount your PC path into the minikube container and then into the POD.

Example:minikube start --mount --mount-string="/host/path:/minikubeContainer/path"


Removing type: Directory from the mongodb.yml works as expected

Update:

In new versions, changing type: Directory by type: DirectoryOrCreate, creates the directory.