In practice I have not seen a container get a different IP address when it was restarted.
It is quite important to keep check of IP changes when you use
iptables to forward connections from the host to a container (Because from container to container you can just use the hostnames).
In your case I would perform tests such as changing the time of the system when a container is about to start again to see whether it gets a new IP address.
However, if you are going to use the LXD
proxy device, you do not need to worry about the IP address of the container. Because instead of specifying the IP address of the container, you can just type
For the host IP address, if you specify
0.0.0.0, then LXD will bind to all interfaces (as long as the port is free on each interface). If you have many network interfaces, you may want to just be explicit here.
That is, your SSH example would look like:
lxc config device add <container-name> sshproxy proxy listen=tcp:0.0.0.0:2222 connect=tcp:localhost:22 bind=host