Linux Containers
Many of CSCF's servers run using LXC (LinuX Containers) (see:
http://en.wikipedia.org/wiki/LXC )
Here we document the most useful commands for working with these containers
Background information
- http://lxc.sourceforge.net/ top-level now redirects to
LXD — Just Say No!
- You may stumble across the presumptuously-named
lxd
package. For now we avoid that for a number of reasons.
Names of current container host servers
Listing the containers on a server
root@mc-cloud002-n1:# lxc-ls
bs002.student.cs.uwaterloo.ca db2a.student.cs.uwaterloo.ca mails.student.cs.uwaterloo.ca postgres060.student.cs.uwaterloo.ca
bs004.student.cs.uwaterloo.ca flexlm202.cscf.uwaterloo.ca mysql070.student.cs.uwaterloo.ca region.student.cs.uwaterloo.ca
bs004.student.cs.uwaterloo.ca flexlm202.cscf.uwaterloo.ca mysql070.student.cs.uwaterloo.ca postgres060.student.cs.uwaterloo.ca
db2a.student.cs.uwaterloo.ca mails.student.cs.uwaterloo.ca postgres060.student.cs.uwaterloo.ca region.student.cs.uwaterloo.ca
root@mc-cloud002-n1:# lxc-ls -l
total 0
drwxr-xr-x 1 root root 56 Nov 13 16:52 bs002.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Nov 15 12:47 bs004.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Feb 11 17:26 db2a.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Sep 5 21:57 flexlm202.cscf.uwaterloo.ca
drwxr-xr-x 1 root root 62 Oct 3 17:37 mails.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Nov 29 15:23 mysql070.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Aug 17 19:24 postgres060.student.cs.uwaterloo.ca
drwxr-xr-x 1 root root 56 Jul 19 2012 region.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 bs004.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Feb 11 17:19 db2a.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 flexlm202.cscf.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 mails.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:23 mysql070.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 postgres060.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 postgres060.student.cs.uwaterloo.ca
drwxr-xr-x 2 root root 0 Nov 29 15:16 region.student.cs.uwaterloo.ca
Get information about a container
- lxc-info --name <container name>
a running system
root@mc-cloud002-n1:# lxc-info --name mails.student.cs.uwaterloo.ca
state: RUNNING
pid: 8331
a stopped system
root@mc-cloud002-n1:# lxc-info --name db2a.cloud.cs.uwaterloo.ca
state: STOPPED
lxc-info: 'db2a.cloud.cs.uwaterloo.ca' is not running
Accessing the console
- lxc-console --name <container name>
root@mc-cloud002-n1:# lxc-console --name mails.student.cs.uwaterloo.ca
Type <Ctrl+a q> to exit the console
Ubuntu 12.04 LTS mails tty1
mails login:
lxc-attach
- You can also use 'lxc-attach --name <container name>' if you don't know the root password
- If you are in the habit of accessing containers via ssh, lxc-attach will allow you access (as super-user on the containing host) if sshd did not start on the container (or is not even installed)