I’ve just verified that cloud-init is available in image alpine/edge/cloud
- but it’s not clear how one can use it during lxd launch
?
I tried the setup which works on ubuntu:
lxc launch images:alpine/edge/cloud blabla -c user.network-config="#cloud-config....."
but it looks it does not work. How can I pass network configuration to Alpine then?
Hi,
Can you post your cloud-configuration?
Thanks.
# NETWORK CONFIG
NC="#cloud-config
version: 1
config:
- type: physical
name: eth0
subnets:
- type: static
ipv4: true
address: $IP_4
netmask: $MASK
gateway: $GW
control: auto
- type: nameserver
address:
- $DNS
search:
- $MAIN_DOMAIN
"
$ are set by config script and filled properly, i hope it is clear
it works for ubuntu hosts
It is not a proper but it is working anyway. You can arrange as a profile like that.
config:
user.user-data: |
#cloud-config
write_files:
- path: /etc/network/interfaces
permissions: 0644
owner: root
content: |
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $IP_4
netmask $MASK
gateway $GW
runcmd:
- rc-service networking restart
description: Test LXD profile
devices:
eth0:
name: eth0
network: lxdbr0
type: nic
root:
path: /
pool: default
type: disk
name: test1
It won’t work as a profile I’m afraid, as it contains variables which are set by installation script during lxd launch

Any other ideas?
Humm, if you can produce the yaml file then everything is possible. A simple example.
indiana@mars:~$ more test.yaml
#cloud-config
users:
- default
- name: foo
gecos: Foo
indiana@mars:~$ lxc launch images:alpine/edge/cloud --config=user.user-data="$(cat test.yaml)"
Creating the instance
Instance name is: inspired-whale
Starting inspired-whale
indiana@mars:~$ lxc exec inspired-whale – getent passwd | grep -i foo
foo:x:1000:1000:Foo:/home/foo:/bin/ash
Whatever I do, I’m unable to set up network configuration. network
specified according to Networking Config Version 1 — cloud-init 21.3 documentation is simply ignored.
My working workaround is:
!/bin/bash
DNS="1.1.1.1"
IP_4="2.2.2.2"
MASK="4.4.4.4"
GW="6.6.6.6"
# USER CONFIG
UC="#cloud-config
write_files:
- content: |
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $IP_4
netmask $MASK
gateway $GW
owner: root:root
path: /etc/network/interfaces
permissions: '0644'
manage_resolv_conf: true
resolv_conf:
nameservers: ['$DNS']
runcmd:
- [ /sbin/reboot ]
"
lxc launch images:alpine/edge/cloud $NAME --config user.user-data="$UC"