Lxd container: port forwarding like docker

containerslxclxdport-forwarding

Is there a way to do port-forwarding in lxd-containers like docker does?

I heard some rumours that there is no easy way.

According to the homepage of lxd this is their goal:

Intuitive (simple, clear API and crisp command line experience)

For me port forwarding is an important part.

I am not in a hurry. If it is planed for a future release, this would be a valid answer.

Best Answer

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).

See https://help.ubuntu.com/lts/serverguide/lxc.html#lxc-network for more information.

So, I'm afraid, as things stand currently, there is no port forwarding, neither now nor in the future. (This prediction turned out to be not true)