minikube/cmd
Nir Soffer a82e25af0e
start: Simpler and safer mount on start (#21250)
The --mount-string argument defaults to `/Users` on darwin, and
homedir.Homedir() on other platforms (e.g. $HOME on unix).

This is wrong in many ways:

- `/Users` is not HOME on darwin (the right path is `/Users/$USER`).
  Using the default mount we cannot access anything inside the guest in
  the user home directory.  We can access the special `/Users/Shared`
  directory, but this should not be a default mount.

- Mounting the user home directory inside the guest in read-write mode
  is a horrible default. This exposes the users private keys in .ssh/ to
  the guest, any sensitive files in the user home directory, and allows
  the guest to change any file on the host.

- Using the `--mount` option mount the default mount directory silently.
  This is unexpected, surprising, and not documented in the minikube
  handbook[1].

Example access to user private key from the guest with the default
mount:

    $ minikube start --mount

    $ minikube ssh cat /minikube-host/.ssh/id_ed25519
    -----BEGIN OPENSSH PRIVATE KEY-----
    ...
    -----END OPENSSH PRIVATE KEY-----

Fixed by removing the default mount directory and changing mount logic
to check for non-empty mount-string instead of the mount flag.

The mount flag is kept for backward compatibility, but its value is
ignored. In the next release we want to use this flag for supporting
multiple mounts.

Example usage before:

    minikube start --mount --mount-string ~/models:/mnt/models

Example usage after:

    minikube start --mount-string ~/models:/mnt/models

Breaking changes:

User depending the default mount will have to replace the command:

    minikube start --mount

With:

    minikube start  --mount-string $HOME:/minikube-host

[1] https://minikube.sigs.k8s.io/docs/handbook/mount/
2025-08-11 11:38:58 -07:00
..
auto-pause fix new lint errors 2024-08-14 10:31:53 -07:00
drivers remove old build tags 2022-03-30 16:43:29 -07:00
extract moving checks to their relevant stops so unit tests work 2019-07-15 13:38:12 -07:00
gvisor Enable gvisor addon in minikube (#3399) 2018-12-07 15:27:22 -08:00
minikube start: Simpler and safer mount on start (#21250) 2025-08-11 11:38:58 -07:00
performance fix lint errors 2024-02-12 17:32:14 -08:00
storage-provisioner Switching from glob library to klog library. 2020-09-29 15:49:41 -07:00