Make service LB work from self

Make service loadbalancing to work from within one of the containers of
the service. Currently this only works when the loadbalancer selects the
current container. If another container of the same service is chosen,
the connection times out. This fix adds a SNAT rule to change the source
IP to the containers primary IP so that responses can be routed back to
this container.

Signed-off-by: Jana Radhakrishnan <mrjana@docker.com>
This commit is contained in:
Jana Radhakrishnan 2016-08-04 17:39:38 -07:00
parent 0030332e4e
commit aced41a3d2
1 changed files with 1 additions and 1 deletions

View File

@ -710,7 +710,7 @@ func fwMarker() {
os.Exit(4)
}
if len(ingressPorts) != 0 && addDelOpt == "-A" {
if addDelOpt == "-A" {
ruleParams := strings.Fields(fmt.Sprintf("-m ipvs --ipvs -j SNAT --to-source %s", os.Args[6]))
if !iptables.Exists("nat", "POSTROUTING", ruleParams...) {
rule := append(strings.Fields("-t nat -A POSTROUTING"), ruleParams...)