我第一次尝试 lxc,按照以下方法https://help.ubuntu.com/lts/serverguide/lxc.html和手册页。
该lxc-create
命令运行时没有错误,并创建 zfs/lxc/u1
文件系统,挂载在 上/lxc/u1/rootfs
。
root@Ubuntu-1604-xenial-64-minimal ~ # lxc-create -t download --bdev zfs --lxcpath=/lxc -n u1 -- --dist ubuntu --release xenial --arch amd64
Setting up the GPG keyring
Downloading the image index
Downloading the rootfs
Downloading the metadata
The image cache is now ready
Unpacking the rootfs
---
You just created an Ubuntu container (release=xenial, arch=amd64, variant=default)
To enable sshd, run: apt-get install openssh-server
For security reason, container images ship without user accounts
and without a root password.
Use lxc-attach or chroot directly into the rootfs to set a root password
or create user accounts.
root@Ubuntu-1604-xenial-64-minimal ~ # lxc-ls --fancy
root@Ubuntu-1604-xenial-64-minimal ~ # zfs list
NAME USED AVAIL REFER MOUNTPOINT
lxc 390M 1.27T 20K /lxc
lxc/u1 389M 1.27T 389M /lxc/u1/rootfs
root@Ubuntu-1604-xenial-64-minimal ~ #
为何lxc-ls
不显示u1
?
我做错了什么?
答案1
我需要添加 --lxcpath=/lxc 到每一个lxc 命令 :(
root@Ubuntu-1604-xenial-64-minimal ~ # sudo lxc-ls --lxcpath=/lxc --fancy
NAME STATE AUTOSTART GROUPS IPV4 IPV6
u1 STOPPED 0 - - -
我修复了这个问题:
echo "lxc.lxcpath = /lxc" > /etc/lxc/lxc.conf