Skip to content

Instantly share code, notes, and snippets.

@pmauduit
Last active March 31, 2016 18:30
Show Gist options
  • Save pmauduit/c3777801f68863f60a628290ea05b4a1 to your computer and use it in GitHub Desktop.
Save pmauduit/c3777801f68863f60a628290ea05b4a1 to your computer and use it in GitHub Desktop.
LXC cheat sheet
lxc.utsname = cont1
lxc.network.type = veth
lxc.network.flags = up
lxc.network.link = lxcbr0
lxc.network.name = eth0
lxc.network.ipv4 = 192.168.0.2/24
lxc.network.ipv4.gateway = 192.168.0.1
lxc.rootfs = /var/lib/lxc/cont1/rootfs
# Common configuration
lxc.include = /usr/share/lxc/config/debian.common.conf
# Container specific configuration
lxc.mount = /var/lib/lxc/cont1/fstab
lxc.utsname = cont1
lxc.arch = amd64
lxc.autodev = 1
lxc.kmsg = 0
# Redirection d'un port (ldap) vers un conteneur LXC
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 389 -j DNAT --to-dest 192.168.0.3:389
# create a new LXC container
lxc-create -n <name> -t debian
# list containers
lxc-ls
# list containers (fancy/useful output)
lxc-ls -f
# start a container (foreground)
lxc-start -n <name>
# background (much more useful)
lxc-start -n <name> -d
# connect onto a running container
lxc-attach -n <name>
# stop a container
lxc-stop -n <name>
# destroy a container
lxc-destroy -n <name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment