Cloud-init support in LXD container images

cloud-init is a tool to help you customize cloud images. When you launch a cloud image, you can provide to it with your cloud-init instructions, and the cloud image will execute them. In that way, you can start with a generic cloud image, and as soon as it booted up, it will be configured to your liking.

In LXD, there are two main repositories of container images,

  1. the «ubuntu:» remote, repository with Ubuntu container images
  2. the «images:» remote, repository with all container images.

Until recently, only container images in the «ubuntu:» remote had support for cloud-init.

Now, container images in the «images:» remote have both a traditional version, and a cloud-init version.

Let’s have a look. We search for the Debian 10 container images. The format of the name of the non-cloud-init containers is debian/10. The cloud-init images have cloud appended to the name, for example, debian/10/cloud. These are the names for the default architecture, and in my case my host runs amd64. You will notice the rest of the supported architectures; these do not run (at least not out of the box) on your host because LXD’s system containers are not virtual machines (no hardware virtualization).

$ lxc image list images:debian/10

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

|              ALIAS               | FINGERPRINT  | PUBLIC |              DESCRIPTION               |  ARCH   |   SIZE   |          UPLOAD DATE          |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10 (7 more)               | b1da98aa0523 | yes    | Debian buster amd64 (20190829_05:24)   | x86_64  | 93.21MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/arm64 (3 more)         | 061bf8e54195 | yes    | Debian buster arm64 (20190829_05:24)   | aarch64 | 89.75MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/armel (3 more)         | f45b56483bcc | yes    | Debian buster armel (20190829_05:53)   | armv7l  | 87.75MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/armhf (3 more)         | 8b3223cb7c36 | yes    | Debian buster armhf (20190829_05:55)   | armv7l  | 88.35MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud (3 more)         | df912811b3c3 | yes    | Debian buster amd64 (20190829_05:24)   | x86_64  | 107.57MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/arm64 (1 more)   | c75bae6267e6 | yes    | Debian buster arm64 (20190829_05:29)   | aarch64 | 103.49MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/armel (1 more)   | a9939000f769 | yes    | Debian buster armel (20190829_06:33)   | armv7l  | 101.43MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/armhf (1 more)   | 8840418a2b4f | yes    | Debian buster armhf (20190829_05:53)   | armv7l  | 101.93MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/i386 (1 more)    | 79ebaba3b386 | yes    | Debian buster i386 (20190829_05:24)    | i686    | 108.85MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/ppc64el (1 more) | dcbfee6585b3 | yes    | Debian buster ppc64el (20190829_05:24) | ppc64le | 109.43MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/cloud/s390x (1 more)   | f2d6a7310ae1 | yes    | Debian buster s390x (20190829_05:24)   | s390x   | 101.93MB | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/i386 (3 more)          | f0bc9e2c267d | yes    | Debian buster i386 (20190829_05:24)    | i686    | 94.41MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/ppc64el (3 more)       | fcf56d73d764 | yes    | Debian buster ppc64el (20190829_05:24) | ppc64le | 94.57MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

| debian/10/s390x (3 more)         | 3481aeba0e06 | yes    | Debian buster s390x (20190829_05:24)   | s390x   | 88.02MB  | Aug 29, 2019 at 12:00am (UTC) |

+----------------------------------+--------------+--------+----------------------------------------+---------+----------+-------------------------------+

I have written a post about using cloud-init with LXD containers.

Another use of cloud-init is to set statically the IP address of the container.

Summary

The container images in the images: remote now have support for cloud-init. Instead of adding clound-init support to the existing images, there are new container names with /cloud appended to them, that have cloud-init support.

Permanent link to this article: https://blog.simos.info/cloud-init-support-in-lxd-container-images/

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.