apt-get install lxc
sudo -i
apt-get install lxc
lxc-ls --fancy
lxc-create -t ubuntu -n mycontainer -d
lxc-ls -f
lxc-start -n mycontainer -d
lxc-atach -n mycontainer
lxc-destroy
apt-get install python-minimal -no-install-recommends
logout
lxc-ls -f ou lxc-ls -f
lxc-create -t ubuntu -n mycontainer
lxc-stop -n mycontainer -k or lxc-start -n mycontainer -d
lxc config set mycontainer limits.cpu 1
lxc config set mycontainer limits.memory 1
lxc exec mycontainer bash
lxc-attach -n mycontainer
ssh ubuntu@containerip
logout or poweroff or shutdown -h now
lxc-freeze -n mycontainer or lxc-unfreeze -n mycontainer
lxc snapshot mycontainer
lxc info mycontainer
lxc restore mycontainer snapshot
lxc-autostart -L
lxc-console
lxc-destroy
sudo ls /cache/lxc/
sudo ls /var/lib/lxc/
cp /things/ /var/lib/lxc/mycontainer/opt/things/
ls /usr/share/templates
lxc-checkconfig
cat /var/lib/lxc/mycontainer/config
#######eof#####
lxc.networking.ipv4 = 10.0.3.100/24 10.0.3.255 #(if dont change the intreface config its kippoing 2 IPs)
lxc.networking.ipv4.gateway = auto
lxc.start.auto = 1
lxc.start.delay = 15
lxc.start.order = 10
#lxc.group = infrastructure,dns #(if active the autostart dont work)
- https://www.youtube.com/playlist?list=PLtK75qxsQaMLwF_uCB_CK8wIE17D-afuJ
- https://stgraber.org/2013/12/20/lxc-1-0-blog-post-series/
sudo apt install lxc-dev
useradd -m -d /home/luisubu luisubu
mkdir -p /home/luisubu/.ssh chown luisubu:luisubu /home/luisubu/.ssh
vi /home/luisubu/.ssh/authorized_keys chmod 0400 /home/luisubu/.ssh/authorized_keys chown luisubu /home/luisubu/.ssh/authorized_keys
groupadd sysadmin
echo '%sysadmin ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/sysadmin
usermod -aG sysadmin luisubu
chsh -s /bin/bash luisubu
Last, ansible depends on Python2 and it isn't present in the basic Ubuntu 16.04 image. Let's install it
sudo apt-get update sudo apt-get install python
https://blog.simos.info/how-to-make-your-lxd-container-get-ip-addresses-from-your-lan/ https://blog.simos.info/how-to-make-your-lxd-containers-get-ip-addresses-from-your-lan-using-a-bridge/
Here is the iptables command. Set three parameters, and then change the $PORT to each port that needs to be opened.
PORT=80 SERVER_IP=your_server_ip CONTAINER_IP=your_container_ip INTERFACE=your_server_network_interface sudo -E bash -c 'iptables -t nat -I PREROUTING -i $INTERFACE -p TCP -d $SERVER_IP --dport $PORT -j DNAT --to-destination $CONTAINER_IP:$PORT -m comment --comment "forward to network port"'
Replace
PORT: the network port. In the example it shows port 80 (www). SERVER_IP: the server’s IP address. CONTAINER_IP: the container’s IP address (use lxc list to find it). INTERFACE: the server network interface. Probably eth0 or something similar.
exemplos:
PORT=8080 PROTO=tcp SERVER_IP=your_server_ip CONTAINER_IP=your_container_ip INTERFACE=your_server_network_interface sudo -E bash -c 'iptables -t nat -I PREROUTING -i $INTERFACE -p $PROTO -d $SERVER_IP --dport $PORT -j DNAT --to-destination $CONTAINER_IP:$PORT -m comment --comment "forward to Kodi network port 8080 TCP"'
PORT=9777 PROTO=udp SERVER_IP=your_server_ip CONTAINER_IP=your_container_ip INTERFACE=your_server_network_interface sudo -E bash -c 'iptables -t nat -I PREROUTING -i $INTERFACE -p $PROTO -d $SERVER_IP --dport $PORT -j DNAT --to-destination $CONTAINER_IP:$PORT -m comment --comment "forward to Kodi network port 8080 TCP"'