Spike
2017-Apr-03 17:52 UTC
[libvirt-users] creating a lxc image to be used with libvirt-lxc
Dear all, I'm moving my first baby steps with libvirt-lxc trying to convert over from an LXD installation and one of the hurdles is putting together an image. All the examples I found about libvirt-lxc refer to running /bin/sh in a container, almost as if it was docker, as opposed to run a "full system" like I've been doing with lxd. Also virt-install, often referred in libvirt docs, seems to be specific/only for kvm. Can anybody point me to any documentation to achieve the same as you'd do with lxd? would it even just work to use those images ( https://cloud-images.ubuntu.com/) with libvirt? Last but not least, is there any way to "publish" a modified image so that I could make changes to any of the above and then reuse the modified one as a base for other containers? thank you, spike
Daniel P. Berrange
2017-Apr-04 09:59 UTC
Re: [libvirt-users] creating a lxc image to be used with libvirt-lxc
On Mon, Apr 03, 2017 at 05:52:33PM +0000, Spike wrote:> Dear all, > > I'm moving my first baby steps with libvirt-lxc trying to convert over from > an LXD installation and one of the hurdles is putting together an image. > > All the examples I found about libvirt-lxc refer to running /bin/sh in a > container, almost as if it was docker, as opposed to run a "full system" > like I've been doing with lxd. Also virt-install, often referred in libvirt > docs, seems to be specific/only for kvm. > > Can anybody point me to any documentation to achieve the same as you'd do > with lxd? would it even just work to use those images ( > https://cloud-images.ubuntu.com/) with libvirt? Last but not least, is > there any way to "publish" a modified image so that I could make changes to > any of the above and then reuse the modified one as a base for other > containers?Libvirt LXC doesn't really care what you run inside the containedr - it is possible to use it to run a single application (docker style), or to run a full operating system. You essentially just need to populate a chroot with the operating system install you want to run. I've previously tested with a Fedora chroot: https://www.berrange.com/posts/2013/08/12/running-a-full-fedora-os-inside-a-libvirt-lxc-guest/ If you want to have layered modifications, then the best bet is probably to make use of overlayfs with your chroots. ie populate a base chroot and treat it as read-only thereafter. Then create a new directory mounted with overlayfs to add a writable layer on top. Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ :|
Spike
2017-Apr-04 17:20 UTC
Re: [libvirt-users] creating a lxc image to be used with libvirt-lxc
ok, thank you Daniel, that helps, I'll see if I can adapt it to other OS and figure out the docker style stuff, it would be useful to run a few things I have in mind. Btw, Daniel, have you ever tried to run libvirt inside a container? I was trying to do so to test things since I didn't want to get all the stuff installed on the host, but I got a whole bunch of errors and virt-manager would not connect no matter what. Also, some more examples, if anybody on the list has them, would be most appreciated to help a noob get started. best, Spike On Tue, Apr 4, 2017 at 2:59 AM Daniel P. Berrange <berrange@redhat.com> wrote:> On Mon, Apr 03, 2017 at 05:52:33PM +0000, Spike wrote: > > Dear all, > > > > I'm moving my first baby steps with libvirt-lxc trying to convert over > from > > an LXD installation and one of the hurdles is putting together an image. > > > > All the examples I found about libvirt-lxc refer to running /bin/sh in a > > container, almost as if it was docker, as opposed to run a "full system" > > like I've been doing with lxd. Also virt-install, often referred in > libvirt > > docs, seems to be specific/only for kvm. > > > > Can anybody point me to any documentation to achieve the same as you'd do > > with lxd? would it even just work to use those images ( > > https://cloud-images.ubuntu.com/) with libvirt? Last but not least, is > > there any way to "publish" a modified image so that I could make changes > to > > any of the above and then reuse the modified one as a base for other > > containers? > > Libvirt LXC doesn't really care what you run inside the containedr - it is > possible to use it to run a single application (docker style), or to run a > full operating system. You essentially just need to populate a chroot with > the operating system install you want to run. > > I've previously tested with a Fedora chroot: > > > https://www.berrange.com/posts/2013/08/12/running-a-full-fedora-os-inside-a-libvirt-lxc-guest/ > > If you want to have layered modifications, then the best bet is probably > to make use of overlayfs with your chroots. ie populate a base chroot > and treat it as read-only thereafter. Then create a new directory mounted > with overlayfs to add a writable layer on top. > > > Regards, > Daniel > -- > |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ > :| > |: http://libvirt.org -o- http://virt-manager.org > :| > |: http://entangle-photo.org -o- http://search.cpan.org/~danberr/ > :| >