Bind on loopback different from 127.0.0.1

Expected behavior

When running docker natively on linux, it is possible to bind on any local ip within 127.0.0.0/8
Running docker run -p 127.0.1.2:80:80 alpine tail -f /dev/null runs successfully
This is useful to have several web servers running concurrently on ‘localhost’

Actual behavior

On docker for mac, EADDRNOTAVAIL is returned:

docker: Error response from daemon: driver failed programming external connectivity on endpoint elegant_yalow (21a6bc7bfc1447056230fe83dcf8a512404585c6ef354eea5d2e1352387023bf): Error starting userland proxy: Failed to bind: EADDRNOTAVAIL.

Information

pinata diagnose -u

OS X: version 10.11.4 (build: 15E65)
Docker.app: version v1.11.1-beta11
Running diagnostic tests:
[OK]      docker-cli
[OK]      Moby booted
[OK]      driver.amd64-linux
[OK]      vmnetd
[OK]      osxfs
[OK]      db
[OK]      slirp
[OK]      menubar
[OK]      environment
[OK]      Docker
[OK]      VT-x
Docker logs are being collected into /tmp/20160517-001725.tar.gz
Most specific failure is: No error was detected
Your unique id is: 2196A655-03A1-4E6C-B579-F5914F4F5C6C
Please quote this in all correspondence.

Steps to reproduce the behavior

docker run --rm -p 127.0.1.2:80:80 alpine tail -f /dev/null

You need to add the address to the interface first. This is not a Docker issue, but OSX specifics. You will not be able to listen on this address also with other daemons.
if you run

sudo ifconfig lo0 add 127.0.1.2 netmask 0xffffffff

your command will work properly.
Docker does have an issue here however, and it’s the fact that you can’t port forward the same port from different IP addresses (which should be perfectly possible): Docker Beta has conflicts when mapping same port on different IPs