Posting this community wiki answer to indicate that the issue was resolved by:
I retried it after deleting Minikube configuration folder "~/.minikube" and updated to Minikube v1.19.0 and it works: minikube start --mount --mount-string="$(pwd):/src"
To check on the whole scenario, I've reproduced it with a following setup:
Ubuntu 20.04
Docker 20.10.7
KVM 4.2.1
Minikube:
v1.22.0 (tested both versions with the same steps)
v1.19.0
I'd reckon the issue was resolved not by deleting the ~/.minikube directory or upgrading minikube but rather than with a change to the destination folder that was mounted.
Assuming a following setup:
$ mkdir ~/test
$ echo "General Kenobi!" > ~/test/hello_there.txt
$ minikube start --mount --mount-string ~/test:/data
$ minikube ssh
$ ls -al /data
total 8
drwxr-xr-x 2 root root 4096 Jul 13 11:45 .
drwxr-xr-x 1 root root 4096 Jul 13 11:45 ..
$ minikube start --mount --mount-string ~/test:/src <-- notice the destination change
$ minikube ssh
$ ls -al /src <-- notice the destination change
total 12
drwxrwxr-x 2 1003 1004 4096 Jul 13 11:42 .
drwxr-xr-x 1 root root 4096 Jul 13 11:47 ..
-rw-rw-r-- 1 1003 1004 16 Jul 13 11:42 hello_there.txt
As it can be seen the files showed correctly when mounted to the directory other than /data.
A side note!
Above scenario was present only with the --driver=docker. --driver=kvm2 mounted the data to /data folder successfully.
This could be related to the persistency of some minikube's directories. More on that can be found here:
Another side note!
$ minikube mount with a /data as destination folder worked correctly.
Additional resources: