0

As part of each test run we need to create new ubuntu lxc and install set of 10-15 packages(using apt-get install and pip install). The installation of additional packages add 5-minutes of run time. Is it possible to have customized lxc images with those packages pre-installed. I dont want to do lxc-clone and lxc-snapshot as i want to keep the networks to which the lxc interfaces attached very dynamic.

Is this doable with lxc and should i switch to docker.

Thanks in advance

user245011
  • 65
  • 1
  • 9

1 Answers1

0

Yes, it is doable; First, you create the image and then install all the required components and then make use of the commands like fakeroot, cpio to create initramfs.gz;

Follow this (backup):

   $ cd /var/lib/lxc/C1/rootfs
   $> find . | fakeroot -i fakeroot.env -s fakeroot.env -- cpio -o -H newc | gzip >"/home/<user>/initramfs.gz"

If you want to create new lxc (like restore) then do the following.

Follow this (restore):

   $ mkdir -p /var/lib/lxc/C2/rootfs
   $ cd /var/lib/lxc/C2/rootfs
   $ cp /home/user/initramfs.gz
   $ gunzip initramfs.gz
   $ cpio -i < initramfs
   $ rm initramfs
   $ cp  /var/lib/lxc/C1/config  /var/lib/lxc/C2/config

Now edit the copied config file to have a new UTS name "C2" and other things which is needed specific to C2;

Viswesn
  • 4,674
  • 2
  • 28
  • 45