开启虚拟化嵌套
检测pve虚拟系统是否支持虚拟化
PVE虚拟出来的vm系统的cpu,默认不支持vmx,即不支持嵌套虚拟化,在虚拟机中使用命令来验证:
egrep --color 'vmx|svm' /proc/cpuinfo
没有输出即不支持,否则会高亮显示vmx或者svm。
开启嵌套虚拟化步骤:
1.开启pve主机的nested,关闭所有虚拟机
检查pve系统是否开启nested,运行命令:
cat /sys/module/kvm_intel/parameters/nested
Y
输出N,表示未开启,输出Y,表示已开启
检查结果未开启,必须关闭所有的虚拟机系统,否则不能开启内核支持。
modprobe -r kvm_intel
modprobe kvm_intel nested=1
# 再次检查nested,输出Y,即为开启成功。
cat /sys/module/kvm_intel/parameters/nested
如果报错Module kvm_intel is in use,请检查你的虚拟机是否全部关闭。
2.设置系统启动后自动开启nested
echo "options kvm_intel nested=1" >> /etc/modprobe.d/modprobe.conf
这样系统重启会自动加载netsted,支持嵌套虚拟了。
LXC 建立
这边我以 ubuntun 18.04 版做测试,在 Proxmox VE先建立一个 ubuntu 18.04 的 LXC,注意这个 LXC 必须是 unprivileged 模式,如下图

新建LXC
安装好 LXC 之后先不要急着启动,接下來必须设定这个 LXC ,如下图,Options => Features => 勾选 keyctl 及 nesting。

修改签名
接着就可以启动这个 LXC,然后就进入 console 准备安装 docker-ce 了。
安装及设置 docker-ce
安装下面步骤安装即可
apt-get update
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
apt-get -y update
apt-get -y install docker-ce
mkdir -p /etc/docker
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://registry.docker-cn.com",
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://cr.console.aliyun.com/"
]
}
EOF
systemctl daemon-reload
systemctl restart docker
这是估计docker已经安装成功了,尽情使用吧!