Publish to virtual IP alias

I administer multiple BIND master / slave servers for the LAN network. These are currently each on dedicated servers, and all hosts use it for DNS. I would like to dockerize them on a single Docker server and consolidate resources better. Since I cannot publish multiple containers to the same port 53/udp, I thought about adding multiple virtual alias (eth0:0, eth0:1, eth0:2 etc) each with static IPs, and publishing 53/udp on each container to each of the virtual aliases. Essentially:

-p 10.10.40.200:53/53/udp
-p 10.10.40.201:53/53/udp
-p 10.10.40.202:53/53/udp

The Docker server will be Linux (probably Arch Linux), but I am prototyping on a Windows laptop. I am thinking of using Alpine for the BIND containers. I added multiple IPs to my Ethernet connection (Network Connections → [connection] → IPv4 → Advanced → IP address → Add…) I can ping these additional IPs from other PCs on the network. However, when I try to run try to publish to this IP it fails as below. Should this scenario work, and if so what am I missing? It works fine if I remove the IP address, but that would mean that I could no longer run multiple DNS slave containers which negates the requirements. Comments appreciated. Thank you.

C:>ping 10.10.40.200

Pinging 10.10.40.200 with 32 bytes of data:
Reply from 10.10.40.200: bytes=32 time<1ms TTL=128
Reply from 10.10.40.200: bytes=32 time<1ms TTL=128
Reply from 10.10.40.200: bytes=32 time<1ms TTL=128
Reply from 10.10.40.200: bytes=32 time<1ms TTL=128

Ping statistics for 10.10.40.200:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

C:>docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

C:>docker run -d --name bind -p 10.10.40.200:53:53/udp alpine
3156bbcd07015c30536b0d5c3e972db4216fb7fcf8a32b0bd15ca29d4fb34551
docker: Error response from daemon: driver failed programming external connectivity on endpoint bind (76aa68c4f15c54bfc895f928a9860aed3aff8042f28b49b9715a21d662d03ea9): Error starting userland proxy: listen udp 10.10.40.200:53: bind: cannot assign requested address.

C:>

A published port can only be bound to an ip on linux.

Hi @meyay. Perhaps I was not being clear; my apologies.
On my Docker server I have multiple IP addresses available: 10.10.40.200, 10.10.40.201, 10.10.40.202… I am trying to bind a single container port to a single IP address, then another container port to another IP address. Unfortunately, this does not seem to be working. What can I do to make this?

You have been clear on your first post and this example looks correct:

This should work:

docker run -d --name bind1 -p 10.10.40.200:53:53/udp alpine
docker run -d --name bind2 -p 10.10.40.201:53:53/udp alpine
docker run -d --name bind3 -p 10.10.40.202:53:53/udp alpine
docker run -d --name bind4 -p 10.10.40.202:53:53/udp alpine

Though, neither on Windows, nor on MacOS. You are simply using the wrong plattform to perform your tests. This is what my last post was about…

1 Like

Thank you @meyay. I was not away of this difference. I’ll setup a Linux box to continue prototyping.
Much appreciated.