'WSL2 (docker) ports are not openend on host

When I run an image through docker in WSL2, the ports are not published on the host machine. Why is this? What can I do to make this work?

Screenshot



Solution 1:[1]

So while I still don't know why this happens (sometimes) it appears a restart fixes it (temporarily?):

(on windows cmd)

> wsl --shutdown

Re-running the same commands as above yields mapped ports also visible ob the windows host machine:

C:\WINDOWS\system32>netstat -ano | findstr 55580
  TCP    127.0.0.1:55580        0.0.0.0:0              ABHÖREN         12392
  TCP    [::1]:55580            [::]:0                 ABHÖREN         12392

The 12392 PID is wslhost.exe

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 F.P