User Tools

Site Tools


lxd:add_container

Add a container on a LXD server

Centos 7 guest os

TODO

Debian 9 guest os

First set its service ip :

export IP=10.1.0.202

Then copy-paste the following :

apt-get install -y bridge-utils iptables curl python
echo "
auto br0
iface br0 inet static
address ${IP}
netmask 255.255.255.255
bridge-ports none
" > /etc/network/interfaces
ifup br0
apt-get install -y bird
echo "
router id ${IP};
protocol kernel {
        scan time 20;
        import all;
        export all;
}
protocol device {
        scan time 20;
}
protocol ospf adyxax {
    area 0.0.0.0 {
        interface \"br0\" { stub; };
        interface \"eth*\";
    };
}" > /etc/bird/bird.conf
systemctl restart bird
echo '#!/usr/bin/env bash
set -eu

iptables -t nat -A POSTROUTING -o eth0 -d 10.1.0.0/24 -j SNAT --to-source '"${IP}" > /etc/rc.local
chmod +x /etc/rc.local
/etc/rc.local
curl https://cfengine-package-repos.s3.amazonaws.com/community_binaries/Community-3.12.0/agent_deb_x86_64/cfengine-community_3.12.0-1_amd64-debian4.deb > cfengine-community_3.12.0-1_amd64-debian4.deb
dpkg -i cfengine-community_3.12.0-1_amd64-debian4.deb
cf-agent --bootstrap 10.1.0.204
cf-agent -K
apt-get install -y openssh-server
apt-get clean

Gentoo guest os

HOSTNAME=test
IP=172.16.5.3/24
lxc launch images:gentoo ${HOSTNAME}
lxc exec ${HOSTNAME} rm -rf /usr/portage
lxc exec ${HOSTNAME} mdkir /usr/portage
lxc config device add ${HOSTNAME} portage disk path=/usr/portage/ source=/usr/portage
lxc exec ${HOSTNAME} TODO net
lxc exec ${HOSTNAME} TODO profile
lxc exec ${HOSTNAME} TODO make.conf
lxd/add_container.txt · Last modified: 2018/09/25 15:00 (external edit)