找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 1730|回复: 27

[虚拟机相关] arm版pve部署lxc容器&docker踩坑指南

[复制链接]
本帖最后由 gasment 于 2024-3-11 16:35 编辑

嫌弃N1的8G emmc了,最近搞了个黑豹x2,刷了个armbian,装了pve,专门用来跑lxc,备份回滚都很方便

踩坑经验发下吧


1、下载arm版模板包
提供几个离线包,防止镜像站没了,有alpine、debian11、ubuntu24
游客,如果您要查看本帖隐藏内容请回复

更多系统模板包可以前往此处下载(找到对应系统包的rootfs.tar.xz,        如/ubuntu/jammy/arm64/default/20240307_08:05/rootfs.tar.xz)
⚠️注意:如需在LXC中安装docker,请使用Ubuntu模板,该debian模板本人测试存在问题,加载容器镜像会报错


2、上传模板包到PVE并部署LXC2-1:登录PVE后台,进入储存空间,上传CT模板,如图:
ℹ️将rootfs.tar.xz改名为容易记忆的(不要改扩展名)后上传

2-2:创建CT(LXC)容器   
如使用ubuntu模板, 按x86方式正常创建即可;
如使用debian模板,有一处要注意:⚠️网络设置不要填写ip信息,指定ip将导致创建容器失败,设为静态,留空即可

               



3、设置LXC容器固定ip
如使用ubuntu模板,可正确应用模板设置的ip,此步略过;
如使用debian模板,需要手动修改:
3-1:开启LXC,进入控制台
ℹ️此时容器内为DHCP,确认网络连接正常
3-2:编辑网络配置文件
  1. #先装个文本编辑工具(以debian/ubuntu为例)
  2. apt-get update
  3. apt install nano -y

  4. #打开网络配置文件
  5. nano /etc/systemd/network/eth0.network

  6. #定位到[Network]字段,修改为
  7. [Network]
  8. Address=192.168.x.xx/24    #ip+掩码
  9. Gateway=192.168.x.x        #网关

  10. #按ctrl+x,再按y确认保存并退出

  11. #重启网络服务
  12. systemctl restart systemd-networkd

  13. #检查配置是否正确
  14. ip -c a  #检查eth0是否存在刚才配置的ip

  15. #重启生效
  16. reboot
复制代码




4、配置ssh登录
ℹ️debian/ubuntu模板包默认不带sshd,需要自行安装配置
进入pve中该lxc的控制台
  1. #安装openssh和文本编辑器软件包
  2. apt-get update
  3. apt install openssh-server nano -y

  4. #编辑sshd配置文件
  5. nano /etc/ssh/sshd_conifg

  6. #查找#PermitRootLogin prohibit-password,删掉#号注释并修改为:
  7. PermitRootLogin yes

  8. #按ctrl+x,再按y确认保存并退出

  9. #重启ssh服务
  10. systemctl restart sshd

  11. #尝试使用ssh工具登录root用户
复制代码

5、安装docker、docker-compose(ubuntu模板)
修改apt源为清华源(arm64使用Ubuntu Ports源)

5-1、备份原件:
  1. cp "/etc/apt/sources.list" "/etc/apt/sources.list.bak"
复制代码
5-2、修改sources.list
  1. nano /etc/apt/sources.list
复制代码
       可以按ctrl+K逐行删除全部内容
       粘贴清华源:
  1. # 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
  2. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
  3. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy main restricted universe multiverse
  4. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
  5. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-updates main restricted universe multiverse
  6. deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse
  7. # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-backports main restricted universe multiverse

  8. deb http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse
  9. # deb-src http://ports.ubuntu.com/ubuntu-ports/ jammy-security main restricted universe multiverse

  10. # 预发布软件源,不建议启用
  11. # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
  12. # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ jammy-proposed main restricted universe multiverse
复制代码
         保存退出
         更新源内容:
  1. apt-get update
复制代码



5-3、安装Docker前准备

         清理之前安装过的残留(可选)
  1. apt-get remove docker docker-engine docker.io containerd runc
复制代码
         安装依赖组件
  1. apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common
复制代码
          添加密钥
  1. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
复制代码
          验证密钥
  1. apt-key fingerprint 0EBFCD88
复制代码
         验证成功的返回信息:
  1. pub rsa4096 2017-02-22 [SCEA]
  2. 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
  3. uid [ unknown] Docker Release (CE deb) <docker@docker.com>
  4. sub rsa4096 2017-02-22 [S]
复制代码
         导入docker官方源
  1. add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
复制代码
         #期间会提示按回车确认导入


5-4、安装docker

  1. apt-get update
  2. apt-get install docker-ce docker-ce-cli containerd.io
  3. #安装完成后查看docker运行状态
  4. docker info
复制代码



5-5、安装docker-compose

  1. apt-get install docker-compose
  2. #验证版本(返回版本号为安装成功)
  3. docker-compose -v
复制代码



5-6、配置Docker镜像加速&迁移储存根目录

        新建docker配置文件
  1. nano /etc/docker/daemon.json
复制代码
         添加文本:
{
"registry-mirrors" : [
    "https://******.mirror.aliyuncs.com",
    "https://registry.docker-cn.com"
  ],
  "data-root": "/mnt/docker-root"
}

         ⚠️修改:https://******.mirror.aliyuncs.com为阿里云镜像加速,具体地址可前往https://cr.console.aliyun.com/登录获取,如图:

           

           ⚠️修改:/mnt/docker-root为docker镜像存储目录,修改为你指定的目录
           修改完成保存退出
             重启docker:
  1. systemctl daemon-reload
  2. systemctl restart docker
复制代码
            如重启报错,请检查/etc/docker/daemon.json的内容和格式,如图:
         

          重启docker完成后,使用docker info命令检查设置,如图:
         

✅你可以正常使用docker了



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

相关帖子

我的恩山、我的无线 The best wifi forum is right here.
6666666666666666666666666 , 确实可以折腾啊。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

有点意思,感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

谢谢分享了谢谢分享了
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

来自手机 | 显示全部楼层
厉害。不错感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

666666666666666666666666
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

太棒了,真的非常感谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

arm版pve还没用过,感谢分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

谢谢,看看能不能用。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

好文,刚好需要,刚在8g的树莓派里面装了pve,找文章找到这个,用上了,可以,谢谢。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

arm版pve部署lxc容器
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

威联通NAS上可以使用吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看怎么样?威联通NAS上可以使用吗?
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

看看,谢谢大佬分享
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

RE: arm版pve部署lxc容器&docker踩坑指南 [修改]
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-28 05:41

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表