Is it possible to set a predifined IP address when creating a container?

Hello,

I’m looking for examples how to create/launch a container with a predefined ipv4.address? Is that possible?

Cheers

Not with lxc launch image name --config in my testing, though not ideal, the following did accomplish what I needed in the end.

Copy default profile called staticip and remove eth0 device.

LXCN=lxcname
lxc init image name --profile staticip
lxc config device add $LXCN eth0 ipv4.address=10.0.3.2 nictype=bridged parent=virbr1

EDIT:

architecture: x86_64
config:
  image.architecture: amd64
  image.description: ubuntu 18.04 LTS amd64 (release) (20190320)
  image.label: release
  image.os: ubuntu
  image.release: bionic
  image.serial: "20190320"
  image.version: "18.04"
  limits.memory: 1024MB
  limits.memory.enforce: soft
  volatile.base_image: 6700bee14eb3034ba4bd0c3d0165f938faa161d2690e919465aab2946490689b
  volatile.eth0.hwaddr: 00:16:3e:2b:c2:ec
  volatile.eth0.name: eth0
  volatile.idmap.base: "0"
  volatile.idmap.next: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.idmap: '[{"Isuid":true,"Isgid":false,"Hostid":165536,"Nsid":0,"Maprange":65536},{"Isuid":false,"Isgid":true,"Hostid":165536,"Nsid":0,"Maprange":65536}]'
  volatile.last_state.power: RUNNING
devices:
  eth0:
    ipv4.address: 10.0.3.2
    nictype: bridged
    parent: virbr1
    type: nic
ephemeral: false
profiles:
- staticip
stateful: false
description: ""

Actually, this didn’t work, the CT still solicited for DHCP address. This behaviour is in contrast to my experience with lxc. Additionally, looking at https://lxd.readthedocs.io/en/latest/containers/#type-nic, there’s missing information about routing. And https://lxd.readthedocs.io/en/latest/api-extensions/#network95routes, seem irrelevant. My suspicion, this has to be done inside the CT? Looking into user.network_mode, though this seem breaking:

Additionally, those user keys have become common with images (support isn’t guaranteed):

Cheers