IPv4 is not assigned when launching an instance from Custom image

I have a question as to how/when an IPv4 gets assigned.

I’ve created an image [alias=‘local/stretch’] from debootstrap. I then proceed to create an instance ‘local-stretch’ from image [ lxc launch local/stretch local-stretch].
Upon listing instances I see that only IPv6 is assigned. No IPv4.
Upon some web search I found that following steps assign a static ip.
lxc network attach lxdbr0 local-stretch eth0 eth0
lxc config device set local-stretch eth0 ipv4.address [host ip is]
and fire up container.
Even then the IPv4 is not assigned.

Did I miss any step in creating an image? Is not assigning IPv4 by design?
Thanks in advance for any help.
PS: Just noticed there’s a thing called distrobuilder. I think that’s the way to go. But if you know answers to above, please post.

Out of interest, is there a reason you’re making images rather than using the pre-built ones?

Can you show the output of lxc config show <container> --expanded please?

Hi Tom, like in Docker, I am trying to figure out how to create our own images with pre-built applications. Primary purpose is learning. Thanks.
Here’s lxc config show output

architecture: x86_64
volatile.base_image: e2673b6d58a9f5aca2dba19bb817f153eb35db16716174e5509c1ad752192bbb
volatile.eth0.host_name: veth25d94872
volatile.eth0.hwaddr: 00:16:3e:d6:cf:82
volatile.idmap.base: “0”
volatile.idmap.current: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.idmap.next: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.idmap: ‘[{“Isuid”:true,“Isgid”:false,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000},{“Isuid”:false,“Isgid”:true,“Hostid”:1000000,“Nsid”:0,“Maprange”:1000000000}]’
volatile.last_state.power: RUNNING
devices: {}
ephemeral: false

  • default
    stateful: false
    description: “”

Did you pass the --expanded option, if so, then it appears your default profile has no network card configured.

Oops, I didn’t see expanded. Please see differences between expanded and non-expanded below

name: eth0
network: lxdbr0
type: nic
path: /
pool: default
type: disk


Now can you show the output of lxc network show lxdbr0 please

ipv4.nat: “true”
ipv6.address: fd42:7f96:ad88:796b::1/64
ipv6.nat: “true”
description: “”
name: lxdbr0
type: bridge

  • /1.0/instances/c1
  • /1.0/instances/cosmic-base
  • /1.0/instances/cosmic-maria
  • /1.0/instances/cosmic-test
  • /1.0/instances/local-stretch
    managed: true
    status: Created
  • none

OK great. So inside your debian 9 container, what is your network config? Have you configured it to use DHCP?

Thanks. I think issue is with my deb9 network conf and not lxd. The /etc/network/interface.d is empty, and /etc/network/interface too only includes interfaces.d directory. I’ll need to figure out how to add / configure eth0.
Thanks in advance again for any help.

Update: After /etc/network/interfaces was modified to include eth0, the container is now getting an IPv4.