How ingress-nginx IP works in DockerForDesktop k8s, with WSL2 enabled?
- [x] I have uploaded Diagnostics
- Diagnostics ID: 0E832B03-ADE4-4DD0-9765-8CE7484462BA/20200607051044
Expected behavior
Before enabled WSL2 for Docker For Desktop Windows. K8S was using Hyper-V VM, the ingress-nginx is using Address:localhost.
Which means after I added a 127.0.0.1 harry.co mapping to HOST file, I can visit http://harry.co in my browser and it will hit the ingress-nginx.
Actual behavior
After enabled WSL2 for Docker For Desktop Windows, the ingress-nginx is using a random IP(192.168.65.3) instead of localhost. But his IP is not accessible from my Windows OS, so I don't how to hit the ingress entry anymore.
Question:
Could you help with me, given WSL2 is enabled, Hyper-V is not used anymore, how can I visit http://harry.co in my browser, and it can hit the ingress-nginx correctly?
I'm not sure if I should post it here in docker/for-win or post it to ingress-nginx, hoping it's the right place here.
Information
Please, help us understand the problem. For instance: It is reproducible. Have this issue after the upgrade and enabled WSL2. -->
- Windows Version: Windows10, version 2004, OS Build 19041.264
- Docker Desktop Version: 2.3.0.3(45519), stable
- Are you running inside a virtualized Windows e.g. on a cloud server or on a mac VM: No, it's a real Win10.
Steps to reproduce the behavior
With the WindowsOS and Docker Desktop Version listed above:
1. Enable WSL2, also with settings like these:

2. Install ingress-nginx with one line of code. reference: Bare-metal install.
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/baremetal/deploy.yaml
After install, verified the ingress-controller pod is up and running.
3. Deploy a simple hello app with this YAML:
kind: Service
apiVersion: v1
metadata:
name: hello
labels:
app: hello
spec:
type: NodePort
ports:
- protocol: TCP
name: http
port: 8080
targetPort: 8080
selector:
app: hello
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: hello
labels:
app: hello
spec:
replicas: 1
selector:
matchLabels:
app: hello
template:
metadata:
labels:
app: hello
spec:
containers:
- name: hello
# image: paulbouwer/hello-kubernetes:1.8
image: gcr.io/google-samples/hello-app:1.0
ports:
- containerPort: 8080
---
apiVersion: networking.k8s.io/v1beta1 # for versions before 1.14 use extensions/v1beta1
kind: Ingress
metadata:
name: hello
# annotations:
# nginx.ingress.kubernetes.io/rewrite-target: /$1
# nginx.ingress.kubernetes.io/whitelist-source-range: 192.168.147.174/32
spec:
rules:
- host: hello.info
http:
paths:
- path: /
backend:
serviceName: hello
servicePort: 8080
Wait a while, verified all pods are up and running, verified the hello app is running on NodePort http://localhost:31644
4. Check up the ingress in k8s:
Found it's address is 192.168.65.3, not localhost.
Cannot ping through 192.168.65.3.

5. Added records in HOST file and try hit ingress entry: Given what's already in HOST file:
# Added by Docker Desktop
192.168.31.183 host.docker.internal
192.168.31.183 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
I tried following 3 records in HOST file(one at a time of course), and visit http://harry.co in the browser, none working.
192.168.31.183 harry.co
192.168.65.3 harry.co
127.0.0.1 harry.co
-
I also tried
kubectl logsto check the ingress-controller pod, didn't see any traffic hitting it. -
I don't know what else I can do here to hit Ingress-Nginx entry, after enabled WSL2, without Hyper-V. After 4 hours Googling without a solution, I end up asking help here.
Thank you.
I had the same problem today setting up my first kubernetes cluster on WSL2. I read the fm over here: https://kubernetes.github.io/ingress-nginx/deploy/ You're using baremetal config so you have to use NodePorts. I decided to use the cloud environment so i can access the cluster via localhost: https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-0.32.0/deploy/static/provider/cloud/deploy.yaml
@MarkusRodler Yes, you are right and thank you! I give it a go again, instead of using Baremetal YAML file to deploy the ingress, I use cloud ones for example the Azure one to deploy the ingress controller, just like you posted. It works now.
Closed issues are locked after 30 days of inactivity. This helps our team focus on active issues.
If you have found a problem that seems similar to this, please open a new issue.
Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle locked