Where can I find config file for Ubuntu 18.04 LXC container?

I am trying to test LXC container and created Ubuntu 18.04 container. To access these container from Host Network machines I created new bridged interface in host /etc/network/interfaces and wanted to modify /var/lib/lxc/container-name/config to provide lxc.network.link, lxc.network.ipv4/6, lxc.network.ipv4/6, lxc.network.veth.pair etc. but to my surprise I’m not able to find the config file at this location. though, I can see default.config file at /etc/lxc.

If i update default.config with lxc.network.link and allow newly created containers to get the IP from DHCP will it work? for creating new container I am using “lxc launch ubuntu:18.04”

" A basic configuration is generated at container creation time with the default’s recommended for the chosen template as well as extra default keys coming from the default.conf file."
Not sure where this container specific configuration file gets created.

Thanks for any help in Advance!


do you want to use plain LXC or LXD ? if the latter, it generally works without any config file.
Differences between LXC and LXD are explained here

So where would I need to change if I need to instruct the container to use different bridge interface then the default one ‘lxcbr0’?
lxc.network.link = lxcbr0 to br0

The default bridge interface for LXD is lxDbr0, not lxcbr0.

Please forgive the lack of knowledge of containers. just started learning.
Yes, it is lxdbr0.
Does my question still stand?

you may find more answers to your questions if you take more time to formulate them. One can feel tired to try to reply to ambiguous questions. Do you mean this ? or that ? or something else ? It’s quicker to just not give any answer.

Anyway, I have no experience on using another bridge since the default one does its job and I see absolutely no reason to use another. I had success on adding to default devices such as a secondary ethernet card, though. I have done it by creating a specific profile (lxc profile) and editing the new profile and adding the new card, like this

  name: red0
  nictype: macvlan
  parent: usbnet0
  type: nic

but you could certainly do the same by adding the device directly to a container. Yeah, this can be done:

lxc config device --help
Manage container devices

  lxc config device [command]

Available Commands:
  add         Add devices to containers or profiles

To provide static ips to newly created lxd containers we can assign ip in container’s ./etc/netplan/50-…yaml file.
You can bash into container by using host machine. open terminal in host and type
“lxc exec bash”


When you use LXD and have created a bridge using LXD (i.e. lxc network create), then the network interface is managed by LXD. This means that you can use LXD to make changes to the network, including to apply static IP addresses.

To figure out whether a network interface is managed, run the following. There are two managed networks, lxdbr0 and lxdbr1.

$ lxc network list
| enp0s12   | physical | NO      |             | 0       |
| lxdbr0    | bridge   | YES     |             | 12      |
| lxdbr1    | bridge   | YES     |             | 0       |

Therefore, you can set a static IP address to a container, let’s say, mycontainer, if you run

lxc stop mycontainer
lxc network attach lxdbr0 mycontainer eth0 eth0
lxc config device set mycontainer eth0 ipv4.address
lxc start mycontainer

That is, by setting the ipv4.address configuration with the appropriate IP address, you can get LXD (with the provided DHCP server) to give the chosen IP address to the container.

Thanks @simos for your reply. Does it means that we can set up static up through multiple ways? if yes, what is the preferred and recommended way to do it?

A container can be configured to set by itself a static IP (or even change IP while running), even though it is attached to the managed bridge provided by LXD.

In most cases it would not make sense to use a managed (by LXD) network interface but still set a static IP address without notifying LXD about it.

The preferred and recommended way to assign a static IP to a container on a managed network interface, is to use the LXD way.

In practice, a container does not get a new IP address when it gets restarted, so some users may even forgo setting a static IP address to a container.

Finally, you would need a static IP address for a container only if you setup, for example, IPTables rules on the host to a particular container. If, instead, you use proxy devices, then you do not need a static IP address for a container, because the proxy device is attached to the container name, not the IP address.

Between containers you would use the hostnames to interact with each other, like mycontainer1.lxd and mycontainer2.lxd.

1 Like

You can only specify static IPs in the LXD config when using bridged networking if the network you’re bridging to is managed (i.e created by LXD, such as lxdbr0). In your case you are bridging to the host’s physical network, so specifying a static IP in the LXD container’s config will have no effect. This is because it modifies the managed DHCP service to allocate the static IP, and when using an unmanaged network it cannot modify the network’s DHCP service.