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

    LXD — Just Say No!

Names of current container host servers

Listing the containers on a server

  • lxc-ls

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

  • lxc-ls -l
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)
Edit | Attach | Watch | Print version | History: r6 < r5 < r4 < r3 < r2 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r6 - 2017-01-18 - AdrianPepper
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback