I have been pondering about LXD and have a question


(Phil Howard) #1

i’m still trying to decide and am thinking about LXD and the advantages of going with LXD instead of LXC. host is Ubuntu Xenial 16.04.5 LTS and i will not be doing a major upgrade until 20.04 LTS (i always do a full fresh install fo a major upgrade).

i have this question about LXD that i am pondering and have been trying to find with Google. can i create a simple basic container on-the-fly with one command or maybe a small few commands if have a directory tree present (not currently in use by anything) that i want to be its rootfs? this container would be one-time use and any file changes should be left as changed in that file tree.

if not, what would be the absolute minimum configuration to do to make a simple container intended for short one-time use? examples?

i do this kind of thing with VMs often enough that i think doing the like with containers would be a plus with much less overhead each time.

this would be container that would probably have nothing else mapped and may well be just a slightly enhanced chroot (which i do many times to avoid the time to do a VM). i have scripted building a VM, so it is easy to do, but all the time to build the drive images is still quite a burden (typically over 4 minutes and sometimes over 12 minutes). i’m hoping containers can cut this to a few seconds.


#2

Hi!

If you really need to use your own rootfs, then you must pack it yourself for either LXC or LXD, using distrobuilder,

Personally, I would suggest to start off with an existing container image, such as ubuntu:18.04, or Ubuntu Minimal, or even images:alpine/edge (really small, you need to learn Alpine Linux). Once you get comfortable with the workflow, you can move to your own rootfs (packaged with distrobuilder).

When you set up LXD, use a storage driver that supports copy on write, such as ZFS, perhaps on a SSD disk. In that way, you will be launching new containers in about a second or so.

If you build your own variant of the Alpine Linux container image with distrowatch, it takes about a second. It’s really fast.


(Phil Howard) #3

Alpine Linux definitely looks interesting. i already have a lot of images that make sense sense to me, such as the ones i use in chroot like for specialized builds.

then you must pack it yourself for either LXC or LXD, using distrobuilder ,

this reflects one of the details i want to lean … just what is this “pack” step. i have downloaded what i believe to be images. i got a directory of a bunch of files, several being tarball, including a big rootfs.tar.xz (i have extracted 3 of these). there is also a big squashfs in there that have not mounted, yet. so is this collection the “pack”?

the kind of understanding i want to have would include the knowledge to reproduce things. i might re-implement parts, i might try to improve things. i might add new tools. i might just need to diagnose an issue.

i am inclined to first experiment with unshare and see what happens with different options on that, then move up from there.


#4

You can either study directly the source of distrobuilder, or read first my two blog posts on distrobuilder. I am somewhat inclined to write more on distrobuilder, and it would be helpful for me to see whether you have any constructive feedback that I could use.


(Phil Howard) #5

studying source is generally very deep and often time consuming. this can be a burden when general concepts is what is needed. but i don’t know enough about distrobuilder to know what i need to know. i don’t yet know what more beyond a rootfs an image needs to have for lxd. for chroot all it needs is the rootfs plus perhaps any documentation or special instructions. for unshare, i have not determined, yet, but it appears to not be too much, depending on how much isolation is intended.