2 ms·
I think one of the culprits of this bad default is docker containers. Since docker by default runs your code in a separate network namespace, in that context '
by TheDong 2y ago
I think one of the culprits of this bad default is docker containers.
Since docker by default runs your code in a separate network namespace, in that context '127.0.0.1' really means "accessible inside the container, effectively nowhere", and '0.0.0.0' means "accessible only on the local machine" (except that's not actually true, check out this open issue lol https://github.com/moby/moby/issues/22054 https://github.com/moby/moby/issues/22054 )
I think that's one reason for some software's default of 0.0.0.0 - people are cargo-culting from stuff that runs in docker and/or people want their stuff to run in docker and work by default.
This is only going to get worse as snap and flatpack become more common, since they have the same property.
- yjftsjthsd-h 2y ago> and '0.0.0.0' means "accessible only on the local machine" I don't think that right? It just means "is available to be mapped out of the container", but you still have to use -p or such for it to do anything
- TheDong 2y agoYou don't have to use -p with docker's default settings. $ docker run --rm --name listen busybox sh -c 'echo hi | nc -l -p 8000' # in another terminal $ docker inspect listen -f '{{ .NetworkSettings.IPAddress }}' 172.17.0.3 $ nc 172.17.0.3 8000 < /dev/null hi Works just fine for accessing it on your local machine. The -p flag is meant to "publish" a port so it's available remotely, from outside of your machine (i.e. to serve nginx to the public internet on a webserver with '-p 80:80' or whatever).
- mardifoufs 2y agoI think that the decision to use 0.0.0.0 in this case predates docker by a lot? Which to me indicates that docker used it because it was already a widespread (bad) default.