How to launch Launch lxd container with predefined ip address

suppose, t as lxd container.
root@vmi307975:~# lxc launch ubuntu:18.04 t Creating t Starting t root@vmi307975:~# lxc list t | RUNNING | **10.119.103.155** (eth0) | fd42:465a:4c31:7538:216:3eff:fe60:9040 (eth0) | CONTAINER | 0
My question:
I want ip address of t container as ‘10.199.103.160’ instead of ‘10.199.103.155’ as self decided by lxd container while launching.

Is there any syntax i can use to launch an lxd container and assign it an ip.

Well maybe I missunderstand something, but shouldn’t it be possible to set an ip adress in a profile?

See for example:
ipv4.address
ipv4.dhcp
ipv4.nat
and in case of ipv6: ipv6.address
from: https://github.com/lxc/lxd/blob/master/doc/networks.md
also: https://github.com/lxc/lxd/blob/master/doc/instances.md#type-nic

But beware, you need to use a managed network for this, as shown by:
lxc network list

Then you would launch the container with your profile:
lxc launch ubuntu:18.04 -p network1

You can also attach and detach profiles to already existing containers.

Thanks Toby for help

1 Like