docker / desktop-linux

Bug reports for Docker Desktop for Linux
https://docs.docker.com/desktop/linux/
73 stars 5 forks source link

Pod volume mounting using hostPath method not mounting directory contents #153

Open jveling-yoti opened 1 year ago

jveling-yoti commented 1 year ago

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 commented 1 year ago

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

TomerGodinger commented 11 months ago

See workaround in the similar issue.