docker port in use

#5738 is resolved by this. The solution isn't great but it does the job -- I ran docker-stress with a concurrency of 50 for close to an hour with zero issues.

The first commit is a rewrite of the portallocator code. I think it's simpler and worth considering, but is not strictly necessary and I will be happy to rewrite the history to elide this.

Thanks!