Comment 7 for bug 512200

Revision history for this message
C Anthony Risinger (extofme) wrote : Re: LXC does not work with lucid host and lucid container

Thomas Bechtold and friends, the lxc-ps command i think is buggy, and the -n flag doesnt work, try using --name instead. the output you are seeing is NOT inside the container, it is the same as what you would see if you simply typed ps. if the process was running in a container/cgroup you would see the container name next to the process, like this:

cr@ph1 ~ $ lxc-ps --name guest-personal-tony
CONTAINER PID TTY TIME CMD
guest-personal-tony 4281 ? 00:00:01 init
guest-personal-tony 4318 ? 00:00:00 syslog-ng
guest-personal-tony 4319 ? 00:00:00 syslog-ng
guest-personal-tony 4370 ? 00:00:00 crond
guest-personal-tony 5768 pts/3 00:00:00 login
guest-personal-tony 5769 pts/3 00:00:00 bash
guest-personal-tony 25747 pts/3 00:00:00 su
guest-personal-tony 25748 pts/3 00:00:00 bash
guest-personal-tony 25851 pts/3 00:15:27 python
guest-personal-tony 31858 ? 00:00:00 dhcpcd
guest-personal-tony 32503 ? 00:00:00 git-daemon

another way of seeing the processes is to look at the cgroup itself:

cr@ph1 ~ $ cat /vps/var/cgroup/guest-personal-tony/tasks
<you will see a list of pids running within this cgroup>

cgroup is a psuedo filesystem, and everything you can do with containers/LXC can be managed by manipulating/echoing values into the files within a mounted cgroup. if you create a folder in a cgroup, you effectively begin a hierarchy of groups/aggregated processes, each with their own limits; notice that once you make a folder in a mounted cgroup, all the device files automagically appear inside it, ready to be manipulated. each process on the system must belong to one and only one node in the hierarchy. read this for a better understanding:

http://www.mjmwired.net/kernel/Documentation/cgroups.txt

to use lxc-console, you must enable tty's inside the container with this configuration option:

lxc.tty = N

where N is the number of tty's you want the container to have. lxc-* tools will connect a pty in the host to a tty in the container. the container is responsible for runny a getty or some kind of handler on the tty. if you enable 3 tty's, you can lxc-console into the container 3 independent times. i use an autologin binary and some agetty options to autologin as root anyone entering from the host.