I’m trying to set up multiple projects for development environments on my Linux Mint 22.3 laptop. I’m running Docker v29.5.2, I’ve setup rootless Docker, and enabled the capability to allow binding to privileged ports. I tend to have multiple projects I work on throughout the day, so I’m trying to configure the networking to avoid conflicts. The idea is to bind service ports on separate loopback IP addresses. For example, with two projects I’m working with today that each use Caddy, one of them looks like this:
ports:
- "127.0.1.2:80:80"
- "127.0.1.2:443:443"
And the other looks like this:
ports:
- "127.0.1.3:80:80"
- "127.0.1.3:443:443"
When I up the first one, everything works fine, docker ps -a shows the container with the exposed ports and mappings, and running sudo ss -nlpt shows:
LISTEN 0 4096 127.0.1.2:80 0.0.0.0:* users:(("rootlesskit",pid=53401,fd=19))
However, when I up the second one, it ends with the error:
Error response from daemon: failed to set up container networking: driver failed programming external connectivity on endpoint myproj-caddy-1 (...): Bind for 127.0.0.1:80 failed: port is already allocated
I find it really odd that it’s complaining about the primary loopback address, since neither service references it (I’ve also confirmed this via docker compose config to ensure I didn’t miss anything). In my research, at least one source mentioned added the IPs specifically to the interface, so I tried that via sudo ip addr add 127.0.1.2/8 dev lo (also for .3), but that doesn’t seem to make a difference.
Am I missing something in my setup to allow the separate loopback IP binding? Is this a limitation in rootless docker? Or maybe a bug in some sort of port allocator in Docker?
Thanks in advance for any pointers.