Container¶
TODO¶
look for creation through debootstrap
Create¶
lxc-create \
--name="container_name" \
--template="debian" \
-- \
--release="stretch" \
--mirror="file:/mirrors/debian/debian-stretch" \
--security-mirror="file:/mirrors/debian/debian-stretch-security" \
Configure¶
In containers/directory/container_name :
config
lxc.include = /usr/share/lxc/config/debian.common.conf
lxc.arch = amd64
lxc.autodev = 1
lxc.kmsg = 0
lxc.mount = /var/lib/lxc/container_name/fstab
lxc.rootfs = /var/lib/lxc/container_name/rootfs
lxc.rootfs.backend = dir
lxc.start.auto = 1
lxc.utsname = hostname
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = br0
lxc.network.name = eth0
lxc.network.veth.pair = container_name
lxc.network.hwaddr = virtual_mac_address
Static addresses variant:
lxc.network.ipv4 = container_ip4/network_mask_bits
lxc.network.ipv6 = container_ip6
fstab
Warning
Do not forget to create the data directories
otherwise the container start process will fail!
data/directory/container_name data none bind,create=dir
/mirrors mirrors none bind,create=dir
rootfs/
TODO Debian configuration
rootfs/etc/network/interfaces.d/eth0
if the container uses DHCP:
auto eth0
iface eth0 inet dhcp
Start¶
Warning
Be patient, for it can take a container
up to 1 minute to get its network stack up!
lxc-start -n "container_name"
lxc-start --name="container_name"
Run command¶
lxc-attach -n "container_name" -- command
lxc-attach --name="container_name" -- command