2

I am using Docker for Windows 2.3.0.4 (stable) backed by WSL2 on Windows 10 version 2004 and with Kubernetes support enabled.

I am trying to create the following pod:

apiVersion: v1
kind: Pod
metadata:
  name: api0
spec:
  volumes:
    - name: "mongo-data"
      hostPath:
        path: "/c/wr/volumes/mongo/data"
  containers:
  - name: db
    image: mongo:3.6.19-xenial
    volumeMounts:
      - mountPath: "/data/db"
        name: "mongo-data"
    resources:
      limits:
        memory: "512Mi"
        cpu: "1"
    ports:
      - containerPort: 27017

I have an issue with the mongo-data volume; when the pod is created via kubectl apply -f api0.yml the pod runs properly and the MongoDB collections are persisted after deleting and re-applying the pod.

But the C:\wr\volumes\mongo\data path that is mounted to the mongo db container does not contain the data files and is always empty

As I mentioned before, the state is persisted somewhere but not in the specified path.

What am I missing?

I tried specifying the path with the following formats:

  • /c/wr/volumes/mongo/data
  • //c/wr/volumes/mongo/data
  • //////c/wr/volumes/mongo/data
  • /mnt/c/wr/volumes/mongo/data

And I even tried referencing the /opt/data path in the wsl filesystem but the data files are never there.

Chedy2149
  • 2,821
  • 4
  • 33
  • 56
  • 1
    Have you followed https://stackoverflow.com/questions/50018812/docker-for-windows-volumes-are-empty to make sure the drive is shared? – Sven Hakvoort Aug 17 '20 at 17:42
  • Yes, the C Drive is shared and I am able to mount directories under C: to docker containers with the docker cli – Chedy2149 Aug 18 '20 at 10:49
  • how exactly you are checking if the `C:\wr\volumes\mongo\data` is empty? Have you been trying stop the pod, move that folder somewhere else and then create folder from scratch, start the pod and check if all the collections persist? – Nick Aug 18 '20 at 14:12
  • I check the content of the folder in the windows file explorer. Hidden Files @Nick ? – Chedy2149 Aug 18 '20 at 15:37
  • please add your PV and PVC configuration files . – Nick Aug 18 '20 at 19:41
  • `kubectl get pods api0 -o wide` shall give you the node the container is running on. Do you have only one Windows node or multiple ones? Are you checking on the correct node? what does `kubectl describe pod api0` say ? Do you see the correct volume mounts there? Are you able you login to the pod and check if the `/data/db` is not empty? – Nick Aug 18 '20 at 19:55
  • @Chedy2149 I am facing the same issue, were you able to resolve it? – Coderji Jan 16 '21 at 15:03
  • @coderji unfortunately no – Chedy2149 Jan 16 '21 at 21:37

0 Answers0