From NixNet
add warning
== Custom Images ==
lxc publish <container>
== LXD Networking ==
{{Note|Ignore all of the IPv6-related steps; this leads to a broken IPv6 configuration! We're working on fixing our setup and will update these docs once we've figured out the issues.|warn}}
Before setting any static IPs, you need to enable stateful DHCPv6 on LXD's virtual NIC. For more info about why, see [ a related thread on LXC's Discouse insance].
lxc network set lxdbr0 ipv6.dhcp.stateful true
To bind a container to a host port with NAT, you need a static IP on the container:<pre>lxc network attach lxdbr0 <instance> eth0 eth0lxc config device set <instance> eth0 ipv4.address=<container-ip> ipv6.address=<container-ip></pre> Then the proxy device needs to be added. Note the square brackets <code>[]</code> surrounding the IPv6 address in the second command.<pre>lxc config device add <instance> port-forward_ipv4 proxy connect=tcp:<container-ip>:<port> listen=tcp:<host-public-ip>:<port> nat=truelxc config device add <instance> port-forward_ipv6 proxy connect=tcp:[Category<container-ip>]:<port> listen=tcp:Admin guides[<host-public-ip>]:<port> nat=true</pre> <code><host-ip></code> needs to be the public IP address of your server. == LXD Storage Mounts =={{Note|The following commands and paths are formatted for internal NixNet usage. You may need change the paths to fit your needs.|reminder}} The LXC help gives this hint when adding a device:<pre>lxc config device add [<remote>:]<container-name> <device-name> disk source=/opt/<service-name> path=opt</pre>This adds a device of type disk to <code><container-name></code>. The <code>source</code> is the host's file path, and <code>path</code> is the path in the container. Due to how permissioning works on unprivileged containers, the mount permissions have to be changed on the host system. Firstly you have to know what gid/uid offset LXD is using for it's containers. In the case of NixNet's setup, the containers are on an offset of 100000, which means the root user in the container has the permissions of user 100000 on the host system.
# LXD NetworkingThe next step is to get the uid/gid of the user that needs to access the mounted files in the container. To get this, simply run <code>id <user></code> on the user.
To bind a container For example, to a host port with NAT, you first need a static IP on get the containeruid of postgres:
lxc attach lxdbr0 <instance> eth0 eth0# id postgreslxc config device set <instance> eth0 ipv48.address0K ./staticuid=70(postgres) gid=70(postgres) groups=<container-ip>70(postgres),70(postgres)
Then We then add these uid/gids to our offset (100000) and chown the proxy device needs to be addedfiles on the host. Again following postgres as an example:
lxc config device add <instance> port-forward proxy connect=tcp:<container# chown -ip>:<port> listen=tcpR 100070:100070 /opt/storage/<hostservice-ip>:<portname>/postgresql/
The mounted files should now show up as being owned by the correct user inside of the container.
[[Category:Admin guides]]