Docker Community Forums

Share and learn in the Docker community.

Binding to multiple external IP's from service container

(xfnguy) #1

I have a host with multiple external IP addresses and I’m running docker with a scalable service. My end goal is to be able to bind to a specific IP address of the host from with in the container. For example I’d like to execute curl --interface ethN where N is the Nth interface in the container bound to the Nth IP address of the docker host.

Is this possible with a docker service?

(David Maze) #2

The container doesn’t know anything about the host’s networking. You specify this sort of thing when you set up published ports in your docker run command.

Say you have a container running a management-oriented Web server. Your host has a “public” IP address, and a “private” IP address You want to publish the service on port 8888 only on the private network. You might run:

docker run -d -p myimage \ --bind

where the second line is a made-up command line to start the daemon.

(xfnguy) #3

The container doesn’t know anything about the host’s networking.

@dmaze are you saying its impossible?

Maybe I should have been more specific. I think what I really need is IP masquerading but for the IP that I choose,

(Sreenivas Makam) #4

1 approach could be modifying the iptables on the host to choose the source ip address that you need. This is not a clean approach…