[LXD 4.2] How to debug cloud-init config

I have a cloud-init config and nothing works when I apply it to my container.


How to debug this ?



Into the host or in the container ? The two not exist in my case. I’m on fedora 32 and use lxd/lxc from snap intallation. But I don’t find other path when I run find command for this two name. An idea ?

These are paths inside the instance

Are you sure your using the cloud-init images ?

How are you applying the config ?

  • lxc init local:my-debian-image d10
  • lxc config set d10 user.user-data - < cloud-init.yml
  • lxc start d10
  • lxc exec d10 -- /bin/bash

But nothing in the instance /var/log :thinking:

The container image needs to have support for cloud-init.
If you use the ubuntu: container images, there is cloud-init support.
If you use the images:.../cloud container images, there is cloud-init support.
If you use other container images, you need to verify if there is cloud-init support.

Note that a quick test for cloud-init support is if the container has the package cloud-init preinstalled.
You can use this heuristic if you want to rule out unsuitable container images.

Okay. In my case it is a custom image from debootstrap. I don’t have cloud-init in my image.
I’m going to see for a solution to install it.


I have difficulties to undestand why the cloud-init installation failed after a chroot on my image.
Here is the log of my attempt:


If someone has an idea …

Okay. I fixed the cloud-init installation problem. I forgot to mount / dev / proc & co in my chroot.

But still no trace of /var/log/cloud-init.log and /var/log/cloud-init-output.log

Your next step is to have a look at

  1. https://github.com/lxc/distrobuilder, the tool that builds the LXD container images
  2. https://github.com/lxc/lxc-ci/tree/master/images, the configuration files for all the LXD container images.

You will notice that distribuilder has instructions to activate cloud-init in the container image. I do not know what exactly it does to the container image.
Your work is to either port your tool that generates your own container image into distrobuilder, or just figure out what distrobuilder does to the container image and do it manually to your own container image.

See https://github.com/lxc/lxc-ci/blob/master/images/ubuntu.yaml which is the configuration for the ubuntu: remote.

Really intresting links :+1:
I have some difficulties to understand how to install a working cloud-init. All my test fail when i do an apt install cloud-init only. I look cloud-init services are all stopped when I run my container from my custom image. It seems that cloud-init not work at all because my working user-data.yaml is’nt apply and no cloud-init log files was created into /var/log. It’s probably because I have to set cloud-init in addition to install it but I find no informations about this in this two git repositories.

If someone have the time to explain what kind of commands are run in the chroot to have a working cloud-init. :wink:

Always the same problem and after a lot of search around the instalation/configuration of cloud-init, I don’t find any good answers about this.

I try to install cloud-init on a custom debian buster image. But just an apt install cloud-init not give me a working support of cloud-init. I foget something important to enable this cloud-init support ?

I can’t help you setup cloud-init in a image but,

Why do you need the custom image if your trying to use cloud-init? Can you not use vendor-data for your setup requirements ?

I just want to use cloud-init for the base provisionning of my own image. After that, I would like to try to play with this image with technos like lxd ; terraform ; ansilble… An having my own vm and container images to build other things from it such as docker base images…

All work is local for the moment and i think to deploy my project on the cloud after… Typically it is to make a full CD-CI project with DevOps/SysAdmin part and Application part but in a full trusted way

[EDIT] With simpler words, It’s to learn:

  • how to build a custom linux image
  • how to optimise it
  • how to package it for differents usage