LXC containers on debian

Some small steps to create lxc containers running alpine on debian. Alpine is a lightweight linux distribution.

This is called independent bridge or masqueraded bridge the containers can talk to each other and out to the internet but not to the host

    
Sudo apt install lxc 

Create /etc/default/lxc-net with the following line

USE_LXC_BRIDGE="true" 

Edit /etc/lxc/default.conf and change the default 

lxc.network.type = empty to this

lxc.net.0.type = veth  

lxc.net.0.link = lxcbr0 l 

lxc.net.0.flags = up  

lxc.net.0.hwaddr = 00:16:3e:xx:xx:xxT 

This will create a template for newly created containers. Run sudo service lxc-net restart


sudo lxc-create -t download -n my-container 

enter the below one by one 

distribution is alpine 

release is edge 

arch is amd64 

lxc-start -n my-container -d 

lxc-attach -n my-container 

sudo lxc-info -n my-container 

lxc-stop -n my-container 

lxc-destroy -n my-container