VPS 安装 LXC

我这里当然不是跟你说装PVE然后装LXC,这样不但不环保,而且…

我这里用的是原生的LXC,不需要替换内核,Ubuntu用户可以直接通过apt install lxd lxd-client安装,其他用户可以通过安装snap然后安装lxd,具体看snap商店.

https://snapcraft.io/install/lxd/debian

然后初始化一下安装(一切默认也没问题):

root@debian:~# lxd init
WARNING: cgroup v2 is not fully supported yet, proceeding with partial confinement
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (dir, lvm, ceph, btrfs) [default=btrfs]: 
Create a new BTRFS pool? (yes/no) [default=yes]: 
Would you like to use an existing empty block device (e.g. a disk or partition)? (yes/no) [default=no]: 
Size in GB of the new loop device (1GB minimum) [default=5GB]: 
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
Would you like the LXD server to be available over the network? (yes/no) [default=no]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] 
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 
root@debian:~# 

然后创起一个Ubuntu.

初次进入容器需要一些方法.

lxc exec ubuntu -- /bin/bash

就可以愉快玩耍了,至于IP怎么转发分配,和普通VM也没什么区别.

当然,LXC是共享宿主内核的,项目的更多内容请看:https://linuxcontainers.org/lxd/getting-started-cli/

全部镜像列表:

https://uk.lxd.images.canonical.com/

由于是外部源,所以要这么用:

lxc launch images:debian/bullseye gitea

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注