-
Notifications
You must be signed in to change notification settings - Fork 678
[proxy] weavewait rewrites /etc/hosts so weave ip is returned first from 'hostname -i' #1079
Conversation
I've tried this with Java's $ weave launch
$ docker $(weave proxy-config) run -ti --rm my-java-app
2c80b6ca84b7/10.128.0.2
$ docker run -ti --rm my-java-app
fc551c2b55a7/172.17.0.5 with code: import java.net.InetAddress;
public class Main {
public static void main(String[] args) {
try {
System.out.println(InetAddress.getLocalHost());
} catch (java.net.UnknownHostException e) {
System.out.println(e);
}
}
} |
checkErr(err) | ||
var oldHosts, newHosts bytes.Buffer | ||
for _, addr := range addrs { | ||
fmt.Fprint(&newHosts, strings.Split(addr.String(), "/")[0], "\t", hostname, "\n") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
93e934a
to
8652ba2
Compare
@@ -19,4 +19,7 @@ COMMITTED_IMAGE=$(proxy docker_on $HOST1 commit c1) | |||
assert_raises "proxy docker_on $HOST1 run --name c2 $COMMITTED_IMAGE" | |||
assert "entrypoint c2" "$(entrypoint $COMMITTED_IMAGE)" | |||
|
|||
# Check weave IP is first ip returned, so java (etc) prefer weave. | |||
assert "proxy docker_on $HOST1 run -e 'WEAVE_CIDR=10.2.1.1/24' $BASE_IMAGE hostname -i | cut -d' ' -f1" "10.2.1.1" |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
As @bboreham points out above, afaict If we want to add the |
8652ba2
to
0e74e46
Compare
Yeah. removing the docker ip seems a bit naughty.. |
Meh. The docker ip should still show up with |
Tried out links with the docker IP removed from /etc/hosts, and they still work fine. Not a big fan of adding yet another flag, but... |
eb8ed82
to
ea52cfd
Compare
ea52cfd
to
386e358
Compare
args = os.Args[1:] | ||
notInExec = true | ||
rewriteHosts = true | ||
) | ||
|
||
if args[0] == "-s" { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
ce441c9
to
e445837
Compare
…rom 'hostname -i' Adds a --no-rewrite-hosts flag to the proxy, and be default, removes the docker IP from hosts. We only discard the docker host when it exists, so --net=none works.
writeHosts(hosts) | ||
} | ||
|
||
func parseHosts() map[string][]string { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
LGTM |
|
||
fields := strings.Fields(line) | ||
if len(fields) > 0 { | ||
ips[fields[0]] = fields[1:] |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Partial fix for #68. Won't help with dynamic
attach/detach
or the weave script.