# All lxc commands require root privileges to run
sudo -i
# Create a container
lxc-create -t ubuntu -n my_first_container
# Show container info (state, ip etc.)
lxc-ls
# or
lxc-ls --fancy
# Start a container
lxc-start -n my_first_container # attach to current console
# or
lxc-start -n my_first_container -d # d: daemon mode
# or
lxc-start -n my_first_container -c /dev/tty4 & # c: bind output to console
# Stop a container
## from the inside
sudo poweroff
# or
sudo shutdown -h now
## from the outside
lxc-stop -n my_first_container
# Freeze a container
lxc-freeze -n my_first_container
# Unfreeze a container
lxc-unfreeze -n my_first_container
# Kill a container
lxc-stop -n my_first_container -k # SIGTERM
# or
kill -15 <pid> # SIGTERM
# or
kill -9 <pid> # SIGKILL
# Attach a container to current console
lxc-attach -n my_first_container