LXD container port forwarding

  1. Create a container in lxd:

$ lxc launch ubuntu:18.04 ubuntu-1804
  1. Now we configure a device and set to listen on a specific port:

$ lxc config device add mycontainer myport80 proxy listen=tcp:0.0.0.0:80 connect=tcp:127.0.0.1:80

Explanation: Here we configure lxc to add a device to the container mycontainer with device named myport80, proxy shows that we are adding lxd proxy device, so we connect "connect=tcp:127.0.0.1:80" conatiner port 80 to host "listen=tcp:0.0.0.0:80" port 80.

Last updated