1 |
On 2/4/19 5:10 PM, Grant Taylor wrote: |
2 |
> Consider the following commands to start the ""container: |
3 |
> |
4 |
> ip netns add myContainer |
5 |
> ip link add myContainer type veth peer name myHost netns myContainer |
6 |
> ip link set myContainer up |
7 |
> ip addr add 192.0.2.1/24 dev myContainer |
8 |
> ip netns exec myContainer ip link set myHost up |
9 |
> ip netns exec myContainer ip addr add 192.0.2.2/24 dev myHost |
10 |
> |
11 |
> Consider the following command to stop the ""container: |
12 |
> |
13 |
> ip netns del myContainer |
14 |
|
15 |
This is the other method that I'm starting containers. |
16 |
|
17 |
unshare --mount=/run/mountns/$container --net=/run/netns/$container |
18 |
--uts=/run/utsns/$container /bin/true |
19 |
|
20 |
nsenter --mount=/run/mountns/$container --net=/run/netns/$container |
21 |
--uts=/run/utsns/$container /bin/hostname $container |
22 |
|
23 |
I can use nsenter to execute similar ip link & addr commands to bring |
24 |
the links up. |
25 |
|
26 |
|
27 |
|
28 |
-- |
29 |
Grant. . . . |
30 |
unix || die |