Ubuntu – How to persist configuration changes accross restart with LXD containers

lxclxdnetworkingserver

I am experimenting with LXD, but I'm stuck with a seamingly simple problem: I can't make my bridge config persistent.

The host server has a birdge br0. By default, lxd managed containers will use lxcbr0 and be on another network.

What I want is a container that will get its IP from my main DHCP server, and share the same network as the rest of my servers.

I managed to do so using this stanza:

lxc config set mycontainer raw.lxc 'lxc.network.link = br0'

This seems to work, but every now and then, the configuration gets lost, and the container falls back onto lxcbr0 !

  • So, is this the right way to get my container to use br0 ?
  • And what is the way to make this persistent for real ?

Best Answer

I solved this using a profile.

lxc config profile edit bridge

Then in the editor:

name: bridge
config: {}
devices:
    eth0:
        nictype: bridged
        parent: br0
        type: nic

And when creating a guest/container, specify the profile

lxc launch ubuntu GUESTNAME -p bridge

Not sure, but assume you can apply the profile to existing guests/containers as well. Have not tried it.

EDIT:
From lxd 0.18 profile is part of main commands:

lxc profile edit bridge

Related Question