19. LXCの仕組み - namespace
● Namespace
○ プロセスに対して、リソースを区切って、 それだけしか見せないため
のもの。
○ 各プロセスのNamespaceは、” /proc/<PID>/ns”を見ると、なんとな
くイメージがつきます。
root@ip-172-30-0-74:/# ls -l /proc/948/ns/
total 0
lrwxrwxrwx 1 root root 0 Feb 1 15:25 ipc -> ipc:[4026531839]
lrwxrwxrwx 1 root root 0 Feb 1 15:25 mnt -> mnt:[4026531840]
lrwxrwxrwx 1 root root 0 Feb 1 15:25 net -> net:[4026531992]
lrwxrwxrwx 1 root root 0 Feb 1 15:25 pid -> pid:[4026531836]
lrwxrwxrwx 1 root root 0 Feb 1 15:25 user -> user:[4026531837]
lrwxrwxrwx 1 root root 0 Feb 1 15:25 uts -> uts:[4026531838]
20. LXCの仕組み - namespace
● Mount Namespace
○ マウントに関するNamespace
# unshare --mount /bin/bash
# mkdir /hoge
# mount -t tmpfs tmpfs /hoge
# touch /hoge/a.txt
# mkdir /hoge/fuga
# ls /hoge
a.txt fuga
# 別のシェルから
ubuntu@ip-172-30-0-74:~$ ls -l /hoge
total 0
21. LXCの仕組み - namespace
● Network Namespace
○ ネットワークに関するNamespace
ubuntu@ip-172-30-0-74:~$ ip link list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
group default link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9001 qdisc pfifo_fast state UP mode
DEFAULT group default qlen 1000 link/ether 06:ce:5f:ee:a3:3b brd ff:ff:ff:ff:ff:ff
3: lxcbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN
mode DEFAULT group default link/ether 16:f9:d9:2e:af:28 brd ff:ff:ff:ff:ff:ff
ubuntu@ip-172-30-0-74:~$ sudo ip netns add hoge
ubuntu@ip-172-30-0-74:~$ ip netns
hoge
ubuntu@ip-172-30-0-74:~$ sudo ip netns exec hoge /bin/bash
root@ip-172-30-0-74:~# ip link list
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN mode DEFAULT group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00