-
Notifications
You must be signed in to change notification settings - Fork 45
/
net.sh
executable file
·63 lines (51 loc) · 1.27 KB
/
net.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
. $(cd ${0%/*};pwd;)/../common.sh
n_bridge=2
n_macvlan=2
name=$(rand_name)
cleanup() {
docker rm -f $name
for n in $(docker network ls --format '{{.Name}}' | grep ^runqtest); do
docker network rm $n &>/dev/null
done
}
trap "cleanup; myexit" EXIT
comment="attach container to multiple networks"
docker create \
--runtime runq \
--rm \
--name $name \
$image sh -c 'rc=$(ls -d /sys/class/net/*|wc -l); exit $rc'
for ((i=0; i<n_bridge; i++)); do
net_name=runqtest-bridge-$i
docker network create -d bridge $net_name
docker network connect $net_name $name
done
for ((i=0; i<n_macvlan; i++)); do
net_name=runqtest-macvlan-$i
docker network create -d macvlan $net_name
docker network connect $net_name $name
done
docker start -ai $name
checkrc $? $((n_bridge + n_macvlan + 2)) "$comment"
#
#
#
comment="exchange ip message via macvlan"
net_name=runqtest-macvlan-42
docker network create -d macvlan --subnet=192.168.42.0/24 $net_name
docker run \
--runtime runq \
--name $name \
--net $net_name \
--ip 192.168.42.2 \
--rm \
-td \
$image sh
docker run \
--runtime runq \
--rm \
--net $net_name \
--ip 192.168.42.3 \
$image ping -c 3 -w 3 -W 3 192.168.42.2
checkrc $? 0 "$comment"