Get started with lxc.

Finally, I got some time!!!!!!


Get lxc started in RHEL. Only for newbie to lxc.


Normally, we clone the lxc from github.com


git clone http://github.com/lxc/lxc.git

Then compile it.

[root@atest-guest lxc]# ./autogen.sh 
[root@atest-guest lxc]# ./configure 
[root@atest-guest lxc]# make
[root@atest-guest lxc]# make install

But unfortunately, there are some problem to start enjoying lxc in rhel.

(1). Default lib is /usr/local/lib/. But it is not in the default libdir in RHEL.

[root@atest-guest lxc]# lxc-ls
lxc-config: error while loading shared libraries: liblxc.so.1: cannot open shared object file: No such file or directory
lxc-config: error while loading shared libraries: liblxc.so.1: cannot open shared object file: No such file or directory
lxc-config: error while loading shared libraries: liblxc.so.1: cannot open shared object file: No such file or directory
.
[root@atest-guest lxc]# locate liblxc.so
/data/lxc/src/lxc/liblxc.so
/usr/local/lib/liblxc.so
/usr/local/lib/liblxc.so.1
/usr/local/lib/liblxc.so.1.1.0.alpha2
[root@atest-guest lxc]# ln -s /usr/local/lib/liblxc.so.1 /usr/lib64/liblxc.so.1
[root@atest-guest lxc]# lxc-ls
[root@atest-guest lxc]# echo $?
0

(2). Please create a br named as lxcbr0.

[root@atest-guest lxc]# lxc-create -t sshd -n sshd
Generating public/private rsa key pair.
Your identification has been saved in /usr/local/var/lib/lxc/ssh1/rootfs/etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /usr/local/var/lib/lxc/ssh1/rootfs/etc/ssh/ssh_host_rsa_key.pub.
The key fingerprint is:
9a:e8:af:2c:d9:2e:4a:d1:0d:b2:a8:23:41:bc:05:72 root@atest-guest
The key's randomart image is:
+--[ RSA 2048]----+
|..E              |
|o..              |
| + o             |
|o * o            |
|o+ . .  S        |
|...  . o         |
|+. o. o          |
|o.+o.            |
|.. +=o.          |
+-----------------+
Generating public/private dsa key pair.
Your identification has been saved in /usr/local/var/lib/lxc/ssh1/rootfs/etc/ssh/ssh_host_dsa_key.
Your public key has been saved in /usr/local/var/lib/lxc/ssh1/rootfs/etc/ssh/ssh_host_dsa_key.pub.
The key fingerprint is:
de:f9:31:bd:ec:7a:d7:4c:9f:e3:0c:ee:97:aa:6b:6d root@atest-guest
The key's randomart image is:
+--[ DSA 1024]----+
|                 |
|                 |
|                 |
|                 |
|        S        |
|       . . . .  .|
|        . o +..o=|
|           o.E+*=|
|          .oBBB+.|
+-----------------+

[root@atest-guest lxc]# lxc-start -n sshd --foreground
lxc-start: conf.c: instantiate_veth: 2855 failed to attach 'vethPVKSIK' to the bridge 'lxcbr0': Operation not permitted
lxc-start: conf.c: lxc_create_network: 3138 failed to create netdev
lxc-start: start.c: lxc_spawn: 829 failed to create the network
lxc-start: start.c: __lxc_start: 1088 failed to spawn 'sshd'
lxc-start: lxc_start.c: main: 345 The container failed to start.
lxc-start: lxc_start.c: main: 349 Additional information can be obtained by setting the --logfile and --logpriority options.
[root@atest-guest lxc]# brctl show
bridge name	bridge id		STP enabled	interfaces
[root@atest-guest lxc]# brctl addbr lxcbr0
[root@atest-guest linux_btrfs]# brctl show
bridge name	bridge id		STP enabled	interfaces
lxcbr0		8000.000000000000	no		

(3). Error about capabilities.

[root@atest-guest lxc]# lxc-start -n sshd --foreground
lxc-start: conf.c: setup_caps: 2337 unknown capability sys_module
lxc-start: conf.c: lxc_setup: 4172 failed to drop capabilities
lxc-start: start.c: do_start: 688 failed to setup the container
lxc-start: sync.c: __sync_wait: 51 invalid sequence number 1. expected 2
lxc-start: start.c: __lxc_start: 1088 failed to spawn 'sshd'
lxc-start: lxc_start.c: main: 345 The container failed to start.
lxc-start: lxc_start.c: main: 349 Additional information can be obtained by setting the --logfile and --logpriority options.
[root@atest-guest lxc]# yum install libcap-devel.x86_64 -y
[root@atest-guest lxc]# ./configure 
....................
Security features:
 - Apparmor: no
 - Linux capabilities: yes
 - seccomp: no
 - SELinux: no
 - cgmanager: no
..........................
[root@atest-guest lxc]# make -j 4
[root@atest-guest lxc]# make install
[root@atest-guest lxc]# lxc-start -n sshd 
[root@atest-guest lxc]# echo $?
0


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值