On a normal Linux system, only root may listen on ports below 1024. Inside a Docker container that rule is switched off, so an app running as an ordinary user can bind port 80 without any extra capability.
Docker sets the sysctl net.ipv4.ip_unprivileged_port_start to 0 in each container’s network namespace. The 20.10 release notes describe it as default sysctls that allow privileged ports with no capabilities. You can see it for yourself:
docker run --rm alpine cat /proc/sys/net/ipv4/ip_unprivileged_port_start
docker run --rm --user 1000 alpine sh -c 'nc -l -p 80 & sleep 1; netstat -ltn'
The first prints 0, and the second shows a listener on port 80 started by user 1000. So when you write your own image, there is no need to run as root just because the app wants port 80, and no need for setcap tricks on the binary.
I find this useful to know when an image’s docs tell you to add NET_BIND_SERVICE. On a current Docker version that is often unnecessary.
There is one exception that catches people out. With --network host the container uses the host’s own network namespace, and the host’s value applies, which is usually 1024. A non-root app on port 80 then fails with permission denied. Older Docker versions and some other runtimes do not set the sysctl either.
Further reading: Docker Engine 20.10 release notes, ip-sysctl kernel documentation