4

I have multiple NICs on my machine and hence multiple externally routable IP addresses.

When I start a container, I want to make the container's virtual eth0 have the IP address of one of my publically visible IP addresses

This is because each of my applications queries its local IP and communicates it to the outside over a proprietary protocol, so all of the iptables tricks wont work

How do I do this?

Jakob Weisblat
  • 7,450
  • 9
  • 37
  • 65
user3871397
  • 81
  • 1
  • 2
  • 1
    Where you say "queries its local IP", you seem to be assuming that the machine will have exactly one IP address, or that the program can figure out which one is best to give to another machine. Neither of these is a safe assumption. Couldn't you just pass in to the application which IP address you want it to use? – Bryan Jul 29 '14 at 10:36

1 Answers1

0

I'm not sure if it's a good practice, but you can pass --net option when you start your container:

docker run --net=host ...

From man docker run:

   --net="bridge"

      Set the Network mode for the container
   'bridge':  creates  a  new network stack for the container on the docker bridge
   'none': no networking for this container
   'container:': reuses  another  container network stack
   'host':   use  the  host  network  stack inside the container.  Note: the host mode  gives  the  container  full access  to local system services such as D-bus and is therefore considered insecure.
Vitaly Isaev
  • 5,392
  • 6
  • 45
  • 64