首先先看看效果,几个容器全开,也占不了多少内存。 折腾了快一天了,总算搞起来了。linux
lxc list +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | centos6 | RUNNING | 10.54.46.127 (eth0) | fd42:20c0:8696:546:216:3eff:feb8:af5c (eth0) | PERSISTENT | 0 | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | centos7 | RUNNING | 10.54.46.130 (eth0) | fd42:20c0:8696:546:216:3eff:feae:3681 (eth0) | PERSISTENT | 0 | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | debian8 | RUNNING | 10.54.46.152 (eth0) | fd42:20c0:8696:546:216:3eff:fe77:b416 (eth0) | PERSISTENT | 0 | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | ubuntu-trusty | RUNNING | 10.54.46.245 (eth0) | fd42:20c0:8696:546:216:3eff:fe47:71ac (eth0) | PERSISTENT | 0 | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+ | ubuntu-xenial | RUNNING | 10.54.46.201 (eth0) | fd42:20c0:8696:546:216:3eff:fe5f:9b78 (eth0) | PERSISTENT | 0 | +---------------+---------+---------------------+----------------------------------------------+------------+-----------+
$ free -h total used free shared buff/cache available Mem: 7.7G 4.0G 212M 405M 3.5G 3.0G Swap: 0B 0B 0B
而后说下怎么搞,首先源码编译直接放弃,源码编译用到了go,而go的几个类库要从golang.org走,被墙了,因此直接放弃(尽管能够经过hosts,可是为了简便起见就不弄了)。golang
而后用ubuntu官方编译好的,就添加ubuntu的ppa好了:ubuntu
sudo add-apt-repository -y ppa:ubuntu-lxc/lxd-stable
这里执行完是不能用的,sources.list里面写的是ubuntu 17.04的开发代号,须要改成16.04的(xenial),顺便把ppa仓库换成中科大的镜像站以加速。centos
echo 'deb http://launchpad.proxy.ustclug.org/ubuntu-lxc/lxd-stable/ubuntu xenial main' | sudo tee /etc/apt/sources.list.d/ubuntu-lxc-ubuntu-lxd-stable-zesty.list
后面这一步最重要,也是折腾到快晚上才搞定的东西,就是调整apt的policy,让lxc系列的安装包走ubuntu的ppa,而不是从deepin的仓库安装,默认状况下deepin的仓库优先级会高于ppa,致使安装到最后由于依赖问题失败。centos7
向/etc/apt/preferences
文件写入如下内容,下降deepin仓库的优先级(即包名冲突的状况下,使用第三方仓库的版本,而非deepin的仓库):code
Package: * Pin: release l=Deepin Pin-Priority: 400
以后刷新仓库安装lxd便可:内存
sudo apt update; sudo apt install -y lxd
后面就彻底按照lxd的手册操做便可,若是须要使用zfs的话,须要自行安装zfsutil-linux包。开发
最后,但愿deepin把lxd收入仓库中,就不用这么折腾了。源码