desktop-linux icon indicating copy to clipboard operation
desktop-linux copied to clipboard

Pod volume mounting using hostPath method not mounting directory contents

Open jveling-yoti opened this issue 2 years ago • 2 comments

  • [x] I have tried with the latest version of Docker Desktop
  • [x] I have tried disabling enabled experimental features
  • [ ] I have uploaded Diagnostics
  • Diagnostics ID:

Expected behavior

Volume mounting with hostPath should work

Actual behavior

Volume mounting with hostPath does not work - a directory exists in the pod container, but the contents is always empty.

Same steps work on Docker Desktop Mac

Information

Attempting to kubectl create -f test-pod.yaml with hostPath volume mounting ignores the contents of the host directory and the mounted directory is always empty

The home directory is shared in the Filesharing tab

Steps to reproduce the behavior

Assuming a docker-desktop kubernetes context and given the following pod config yaml, and a directory on the host machine at the defined location below (e.g /home/user/workspace/test) which contains a file helloworld.txt

apiVersion: v1
kind: Pod
metadata:
  name: test-pod
  namespace: app
spec:
  containers:
  - command: ["/bin/bash"]
    name: hello-world-container
    image: ubuntu:22.04
    imagePullPolicy: IfNotPresent
    stdin: true
    tty: true
    ports:
    - containerPort: 8000
    # Mount the volume into the pod
    # Vagrant by default mounts the directory with the vagrant file under /vagrant
    # we have the Vagrantfile in the root of yoti-backend
    volumeMounts:
    - mountPath: /test
      name: test   # must match the name of the volume, above
  volumes:
    - name: test
      hostPath:
        path: /home/user/workspace/test/
        type: DirectoryOrCreate

running kubectl create -f test-pod.yaml successfully deploys the pod, but when "exec ing" into the pod, the expected test directory is always empty

root@test-pod:/# ls -l test/
total 0

Perhaps a VM issue with path mapping?

jveling-yoti avatar May 19 '23 08:05 jveling-yoti

similar issue described here https://github.com/docker/desktop-linux/issues/124

jveling-yoti avatar May 19 '23 08:05 jveling-yoti

See workaround in the similar issue.

TomerGodinger avatar Aug 06 '23 09:08 TomerGodinger