Skip to content

Commit b2c2ea4

Browse files
committed
fix: Warn about using the ignored --mount option
1 parent e4c8917 commit b2c2ea4

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cmd/minikube/cmd/start.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,10 @@ func runStart(cmd *cobra.Command, _ []string) {
269269

270270
validateBuiltImageVersion(starter.Runner, ds.Name)
271271

272+
if viper.GetBool(createMount) {
273+
warnAboutMountFlag()
274+
}
275+
272276
if existing != nil && driver.IsKIC(existing.Driver) && viper.GetString(mountString) != "" {
273277
old := ""
274278
if len(existing.ContainerVolumeMounts) > 0 {
@@ -2099,3 +2103,22 @@ func startNerdctld() {
20992103
exit.Error(reason.StartNerdctld, fmt.Sprintf("Failed to set up DOCKER_HOST: %s", rest.Output()), err)
21002104
}
21012105
}
2106+
2107+
func warnAboutMountFlag() {
2108+
homeDir, err := os.UserHomeDir()
2109+
if err != nil {
2110+
out.WarningT("Failed to get home directory: {{.err}}", out.V{"err": err})
2111+
}
2112+
2113+
// Detect usage of --mount without --mount-string
2114+
if viper.Get(mountString) == "" {
2115+
out.WarningT("The --mount flag is ignored.")
2116+
out.Styled(style.Tip, "To mount a host folder, please use the --mount-string flag.")
2117+
out.Styled(style.Option, "Example: minikube start --mount-string=\"{{.home}}/shared:/mnt/shared\"", out.V{"home": homeDir})
2118+
}
2119+
2120+
// Detect usage of --mount with --mount-string
2121+
if viper.Get(mountString) != "" {
2122+
out.WarningT("The --mount flag is ignored when --mount-string is specified and is not needed.")
2123+
}
2124+
}

0 commit comments

Comments
 (0)