File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ import (
31
31
"github.com/spf13/cobra"
32
32
"k8s.io/klog/v2"
33
33
"k8s.io/minikube/pkg/minikube/cluster"
34
+ "k8s.io/minikube/pkg/minikube/detect"
34
35
"k8s.io/minikube/pkg/minikube/driver"
35
36
"k8s.io/minikube/pkg/minikube/exit"
36
37
"k8s.io/minikube/pkg/minikube/mustload"
@@ -111,7 +112,19 @@ var mountCmd = &cobra.Command{
111
112
var ip net.IP
112
113
var err error
113
114
if mountIP == "" {
114
- ip , err = cluster .HostIP (co .CP .Host , co .Config .Name )
115
+ if detect .IsMicrosoftWSL () {
116
+ klog .Infof ("Selecting IP for WSL. This may be incorrect..." )
117
+ ip , err = func () (net.IP , error ) {
118
+ conn , err := net .Dial ("udp" , "8.8.8.8:80" )
119
+ if err != nil {
120
+ return nil , err
121
+ }
122
+ defer conn .Close ()
123
+ return conn .LocalAddr ().(* net.UDPAddr ).IP , nil
124
+ }()
125
+ } else {
126
+ ip , err = cluster .HostIP (co .CP .Host , co .Config .Name )
127
+ }
115
128
if err != nil {
116
129
exit .Error (reason .IfHostIP , "Error getting the host IP address to use from within the VM" , err )
117
130
}
You can’t perform that action at this time.
0 commit comments