search by tags

for the user

adventures into the land of the command line

openvz \ lxc cheatsheet

LXC

list containers

$ sudo lxc-ls -f
$ sudo lxc-ls --fancy

start a container

$ sudo lxc-start --name u1 --daemon

check a container’s info

$ sudo lxc-info --name u1

stop a container

$ sudo lxc-stop --name u1

delete a container

$ sudo lxc-destroy --name u1

make a container autostart

$ vim /var/lib/lxc/my_groovy_container/config

lxc.start.auto = 1

migrate an lxc container from one host to another

on server 1:

$ tar --numeric-owner -zcvf mylxccontainer.tar.gz -C /var/lib/lxc/mylxccontainer/ .
$ scp mylxccontainer.tar.gz [email protected]:/tmp/
$ lxc-stop --name mylxccontainer

on server 2:

$ chown root:root /tmp/mylxccontainer.tar.gz
$ mkdir /var/lib/lxc/mylxccontainer/
$ tar --numeric-owner -xzvf /tmp/mylxccontainer.tar.gz -C /var/lib/lxc/mylxccontainer/
$ lxc-start --name mylxccontainer --daemon

OPENVZ

list containers

$ sudo vzlist

enter a container

$ sudo vzctl enter 1234