Generate ubuntu18 and ubuntu18.root files from ubuntu:18.04 LXC Image

I have ubuntu:18.04 LXC Images downloaded in my local machine, I just want to convert that
ubuntu 18.04 LXC Image into ubuntu18 and ubuntu18.root file. How can i do that?

A container image is made of a pair of

  1. the metadata file
  2. the rootfs (as a squashfs image)

You can export any container image to those pairs of files.

Let’s see with a locally cached container image.

$ lxc image list
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+
| ALIAS | FINGERPRINT  | PUBLIC |                 DESCRIPTION                 |  ARCH  |   SIZE   |         UPLOAD DATE          |
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+
| u18   | 0b969c724698 | no     | ubuntu 18.04 LTS amd64 (release) (20190307) | x86_64 | 177.72MB | Mar 8, 2019 at 10:21am (UTC) |
+-------+--------------+--------+---------------------------------------------+--------+----------+------------------------------+

We export it with lxc image export.

$ lxc image export 0b969c724698
Image exported successfully!     
$ ls -l
total 181984
-rw-r--r-- 1 myusername myusername 186347520 Mar  21 11:46 0b969c724698d2337eba00540128e26b17ff608a761c28fe7f91b9aef14c3a6e.squashfs
-rw-r--r-- 1 myusername myusername       788 Mar  21 11:46 meta-0b969c724698d2337eba00540128e26b17ff608a761c28fe7f91b9aef14c3a6e.tar.xz
$ tar tvfa meta-0b969c724698d2337eba00540128e26b17ff608a761c28fe7f91b9aef14c3a6e.tar.xz 
-rw-r--r-- root/root      1048 2019-03-07 18:39 metadata.yaml
drwxr-xr-x root/root         0 2019-03-07 18:39 templates/
-rw-r--r-- root/root       110 2019-03-07 18:39 templates/cloud-init-meta.tpl
-rw-r--r-- root/root       324 2019-03-07 18:39 templates/cloud-init-network.tpl
-rw-r--r-- root/root        55 2019-03-07 18:39 templates/cloud-init-user.tpl
-rw-r--r-- root/root        21 2019-03-07 18:39 templates/hostname.tpl
-rw-r--r-- root/root        57 2019-03-07 18:39 templates/cloud-init-vendor.tpl

We can do the same with any container image from any container image repository.
For example,

$ lxc image list ubuntu:
...
$ lxc image export ubuntu:18.04
Exporting the image: rootfs: 50% (9.48MB/s)    
Image exported successfully!                   
$ ls
ubuntu-18.04-server-cloudimg-amd64-lxd.tar.xz
ubuntu-18.04-server-cloudimg-amd64.squashfs
$ 
1 Like

yes, I was able to generate ubuntu18 and ubuntu18.root files from ubuntu:18.04 LXC Image

sudo lxc image export ubuntu18

It will generate ubuntu18 and ubuntu18.04 in the current Directory

Indeed.

Note that the commands that start with lxc (as in lxc image export ...) are part of LXD. If the commands are like lxc-create, lxc-start, lxc-attach, then these are LXC commands. See the difference between LXC and LXD.