1

I want to run a command for each container that is created using my profile. The profile looks like this:

config:
  user.user-data: |
    #cloud-config
    package_upgrade: true
    packages:
      - python3
    runcmd:
      - "touch /tmp/test.txt"
description: Description
devices:
  eth0:
    name: eth0
    nictype: macvlan
    parent: enp4s0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: my-profile

The /tmp/test.txt file is just not there when I log into my running container. And that is an issue. The worst part is that there are no error messages or any other logs that could help.

According to their documentation, runcmd does exist as an option in "cloud-init".

foki
  • 8,624
  • 6
  • 33
  • 32

1 Answers1

0

Which image are you using?

https://linuxcontainers.org/lxd/docs/master/cloud-init/#cloud-init

Before trying to use it, however, first determine which image source you are about to use as not all images have the cloud-init package installed.

The images from the ubuntu and ubuntu-daily remotes are all cloud-init enabled. Images from the imagesremote havecloud-initenabled variants using the/cloudsuffix, e.g.images:ubuntu/22.04/cloud`.

natskvi
  • 125
  • 2
  • 9