Setup
I have this setup:
Windows 10 pro
withWSL2
with anUbuntu 20.04
inside.- Inside the Ubuntu, I have a running
docker engine
that has been working perfectly for over during months, exposing multiple ranges of ports with dozens of images and containers. All perfect.
NFS version 3 and port 111
Today I was playing with an NFS server that must be run on version 3. Port 111
is required in addition to port 2049
. The original test was with the image erichough/nfs-server
.
I narrowed down to problem to this minimum failing example:
If I do this:
docker run -it --rm -p 111:111 alpine
I get this:
docker: Error response from daemon: driver failed programming external connectivity on endpoint hardcore_kilby (9aa7466f1771c9b5926a00eede289fc1084a12ee09ea2f3deee917c4734034c9): Error starting userland proxy: listen tcp4 0.0.0.0:111: bind: address already in use.
This suggests that port 111
is used in the host.
To discard it's not something related to the well-known ports range I bound a different port: 112
instead of 111
, and it succeeded:
Therefore I thought there's a process listening on port 111
.
Nobody on port 111?
This answer on StackOverflow says that Resource monitor can do the job of finding "what process is blocking a port". I launched it, sorted the listing of "Listening ports" by "Port" and....
Oh surprise!!! there's nobody listening on port 111
!
Is RPC blocking the port?
The answer below from @Drixter suggests netstat -tapneu
to see if the port 111
is blocked by RPC.
On the linux side
netstat -tapneu
only works on the linux side of the WSL and reports no port 111
being used.
On the windows side
On the windows side of the WSL (for example via git-bash) the -u
option does not exist, the -e
option collapses the results to statistics, and the -p
requires an extra parameter. So I narrowed down to netstat -tan
and also netstat -n
.
And none of those reports port 111
.
Going deeper
My computer has a fixed IP address in a LAN at 192.168.3.xx
. If I specify the IP for the -p
option, I can see that port 111
is only used on loopback: 127.0.0.1
(also in the rest of lo
addresses like 127.0.0.2
, 127.0.0.3
, etc) but, instead, the port is free on the LAN address:
Why?
- Why is this happening?
- In my case the IP is static. Should I only expose
111
on the docker container to the host on the LAN address and can never be done in thelocalhost
address? - Can it be that the port
111
is used but "not detectable"? - Can I see if I do have this RPC thing and its status on the windows side?