Four years later, the prediction given in this answer was fortunately too pesimisitc. Port forwarding has been implementented in LXD in the meantime as is documented here.
To forward port 80 on the host to 8080 in the container, simply do
One of the developers wrote in this issue about the topic:
This has been closed, but to give a clear answer: lxd (at least as
currently intended) will not do host networking. So in general
you would port-forward to a web-server in a lxd container the same
way you would do with lxc - you can pass in a nic from the host
into the container and have your local router provide it its own
address; or use route-based networking to container veths; or
use iptables forwarding to forward host traffic into the container
(which is what I usually do).
Not sure if this helps you, but it’s possible to just assign a network interface to your container. So, there isn’t so much need to do port forwarding any more…
@gf_yesterday you said “it’s possible to assign a network interface to your container”. I can handle this solution (assigning a new network interface) … but I am lazy. I prefer port forwarding.
There’s no easy way only if iptables -t nat -I PREROUTING -d <IP> -p tcp --dport <port> -j DNAT --to <IP>:<port> is hard. Incidentally, if you’re going to work from rumours, you probably want to ask the source of the rumours, not other people.