Still confused why docker works when you make a process listen to 0.0.0.0 but not 127.0.0.1

docker is "a different machine" and your machine gets a port forward to that machine on localhost.

So when the app inside docker listens to 127.0.0.1 that is only valid inside that machine, to connect to it from "outside" you need to listen to the any address.

So there is 2 different 127.0.0.1.

If you listen to any (0.0.0.0) then it is also available on 127.0.0.1, and all other interfaces/IPs on the machine.