[proxy] rewrite /etc/hosts from outside the container
Avoids problems when container user is non-root. Added a test for this and the --no-rewrite-hosts flag.
This commit is contained in:
1 parent
3180c67151
commit
f55655216f
6 files changed
+172
-117
No files matched your search
@@ -19,9 +19,6 @@ 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"
|
||||
|
||||
# Check exec works on containers without weavewait
|
||||
docker_on $HOST1 run -dit --name c3 $SMALL_IMAGE /bin/sh
|
||||
assert_raises "proxy docker_on $HOST1 exec c3 true"
|
||||
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#! /bin/bash
|
||||
|
||||
. ./config.sh
|
||||
|
||||
expected_ip=10.2.1.1
|
||||
|
||||
image_ip() {
|
||||
proxy docker_on $HOST1 run -e "WEAVE_CIDR=$expected_ip/24" $1 hostname -i | cut -d' ' -f1
|
||||
}
|
||||
|
||||
start_suite "Proxy rewrites hosts file"
|
||||
|
||||
# Default rewrites the host file
|
||||
weave_on $HOST1 launch-proxy
|
||||
assert "image_ip $SMALL_IMAGE" $expected_ip
|
||||
|
||||
# When container user is non-root
|
||||
docker_on $HOST1 build -t non-root >/dev/null - <<- EOF
|
||||
FROM $SMALL_IMAGE
|
||||
RUN adduser -D -s /bin/sh user
|
||||
ENV HOME /home/user
|
||||
USER user
|
||||
CMD true
|
||||
EOF
|
||||
assert "image_ip non-root" $expected_ip
|
||||
|
||||
# When rewrite hosts is disabled
|
||||
weave_on $HOST1 stop-proxy
|
||||
weave_on $HOST1 launch-proxy --no-rewrite-hosts
|
||||
assert_raises "image_ip $SMALL_IMAGE | grep -v $expected_ip"
|
||||
|
||||
end_suite
|
||||
Reference in new issue
Block a user