Adding additional IP addresses to a container

Good day all–

I’m a touch amazed that I can’t figure this out from the documentation or with the almighty web search. I have a device under test that acts as a proxy. I’ve figured out how to start it with a single IP address:

  • create a network (e.g. mynet and subnet – 172.20.0.0/16)
  • use the run command to create a container on mynet with a specified address (e.g. 172.0.0.1)

This all works trivially. However, I can’t figure out how to do two (related) things:

  • add another ip (e.g. 172.0.0.2) to the same container.
  • even if I could, I can’t figure out how to do it prior to the entrypoint executing.

Ideally, I could do something like the following:

docker run --net mynet --ip 172.20.0.2 --ip 172.20.0.3 --name myproxy …

but I’ve tested that and you only start the container with the .3 on eth0. Likewise, I’ve tried using the
docker network connect command but I get an error that makes me think this isn’t possible:

Error response from daemon: endpoint with name mynet already exists in network mynet

Maybe I’m missing something fundamental by thinking that a container could service more than one IP address on a network.

Workaround: it occurred to me that I could do something egregious like have multiple networks (e.g. mynet1 and mynet2) that are defined like the following: 172.20.0.2/32 and 172.20.0.3/32 but that’s about as palatable as brussel sprouts.

If you’ve read this far, thx for the attention.