refuse to attach containers running in the host network namespace
Since bad things happen otherwise, i.e. we end up creating veth pairs with an ethwe on the host Closes #270.
This commit is contained in:
1 parent
73bbb95f7f
commit
f3faf83321
1 file changed
+5
@@ -194,6 +194,11 @@ with_container_netns () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
connect_container_to_bridge() {
|
connect_container_to_bridge() {
|
||||||
|
if [ "$(readlink /proc/$CONTAINER_PID/ns/net)" = "$(readlink /proc/$$/ns/net)" ] ; then
|
||||||
|
echo "Container is running in the host network namespace, and therefore cannot be" >&2
|
||||||
|
echo "connected to weave. Perhaps the container was started with --net=host." >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then
|
if ! ip link add name $LOCAL_IFNAME mtu $MTU type veth peer name $GUEST_IFNAME mtu $MTU ; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in new issue
Block a user