凌木白

文章 分类 评论
44 6 2

站点介绍

木白 & 耙耙柑 & 瑶瑶 的生活琐碎

PVE安装Debian的LXC容器运行Docker

凌木白 2023-11-15 5 0条评论 瞎鼓捣 PVELXCDocker

首页 / 正文

PVE安装Debian的LXC容器运行docker

检测PVE虚拟系统是否支持虚拟化
PVE虚拟出来的vm系统的cpu,默认不支持vmx,即不支持嵌套虚拟化,在虚拟机中使用命令来验证
#没有输出即不支持,否则会高亮显示vmx或者svm。
egrep --color 'vmx|svm' /proc/cpuinfo

一、开启嵌套虚拟化步骤

  1. 关闭所有虚拟机,开启pve主机的nested

    检查pve系统是否开启nested,运行命令:
#输出N,表示未开启,输出Y,表示已开启
cat /sys/module/kvm_intel/parameters/nested
Y
  1. 检查结果未开启,必须关闭所有的虚拟机系统,否则不能开启内核支持。
modprobe -r kvm_intel
modprobe kvm_intel nested=1
# 再次检查nested,输出Y,即为开启成功。
cat /sys/module/kvm_intel/parameters/nested  
如果报错Module kvm_intel is in use,请检查你的虚拟机是否全部关闭。
  1. 设置系统启动后自动开启nested
echo "options kvm_intel nested=1" >> /etc/modprobe.d/modprobe.conf
创建Debian 12的LXC容器

二、PVE映射LXC权限

#101为容器的编号
nano /etc/pve/lxc/101.conf
#添加以下内容
lxc.apparmor.profile: unconfined
lxc.cgroup.devices.allow: a
lxc.cap.drop:
设置Debian LXC
选项,开机启动,设置为 是
选项,功能,勾选嵌套、NFS、SMB/CIFS,方便后续安装docker
控制台,使用root&密码进入终端

三、Debian换源

  1. 备份原文件
mv /etc/apt/sources.list /etc/apt/sources.list.bak
  1. 更换清华源
nano /etc/apt/sources.list

#复制以下内容
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

三、安装Docker

  1. 一键安装脚本
curl -s https://get.docker.com/ | sh
  1. 配置Docker开机启动
#启动
systemctl start docker

# 查看docker状态
docker stats

# 设置开机启动
systemctl enable docker

# 重启系统
reoot 
  1. Docker更换国内源
nano /etc/docker/daemon.json

#复制以下内容
{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com/"
  ]
}

四、可选安装CasaOS

  1. 一键安装脚本
curl -fsSL https://get.casaos.io | sudo bash

评论(0)

热门文章

最新评论

  • 安知鱼

    简单点好呀hhh

  • 言幻真

    瞎折腾得点啥东西!

日历

2025年12月

 123456
78910111213
14151617181920
21222324252627
28293031   

文章目录