[Lxc-users] a newbie question, trying lxc on Debian :-

Fajar A. Nugraha list at fajar.net
Sun Sep 15 11:08:45 UTC 2013


On Sun, Sep 15, 2013 at 4:53 PM, Alex <equetts at gmail.com> wrote:

> I'm after a simple example how to configure and run lxc from scratch on
> Debian Wheezy (e.g. configuring a lxc container manually to run a single
> process within a container, no networking, would be good).
>
>
Good luck with that :)


> All suggestions appreciated.
>
>
It depends on what you need.

A container is a combination of lots of things like chroot and various
namespaces. I suggest you start by reading
http://lwn.net/Articles/531114/ . For
example, if you have a rogue program that binds to all iP addresses by
default and would like to restrict it to only use one IP address, you might
find network namespaces most useful.

If you want the least-painful-way to learn about lxc, I'd  recommend using
ubuntu as the host, create a container using the ubuntu template, and then
install "lxc" package inside the container as well (since you need this to
be able to run "lxc-execute").

Something that "run a single process within a container" would be
lxc-execute, but in my experience it doesn't behave the way you want it to.
For example, if you have /usr/lib/x86_64-linux-gnu/lxc/lxc-init inside the
container (i.e. you have "lxc" package installed inside the container as
well), these commands somewhat work ("ffmpeg" is the name of my container):

# lxc-execute -n ffmpeg -- ls
lxc-init: failed to mount /dev/shm : No such file or directory
bin  boot  core  data  dev  etc  home  lib  lib64  media  mnt  opt  proc
 root run  sbin  selinux  srv  sys  tmp  usr var

# lxc-execute -n ffmpeg -- ps -efa
lxc-init: failed to mount /dev/shm : No such file or directory
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  2 11:03 ?        00:00:00 /usr/lib/lxc/lxc-init -- ps
-efa
root         2     1  0 11:03 ?        00:00:00 ps -efa


... while an interactive shell doesn't work the way I want it to

# lxc-execute -n ffmpeg -- bash
lxc-init: failed to mount /dev/shm : No such file or directory
root at ffmpeg:/# root at ffmpeg:/# root at ffmpeg:/# lxc-execute: Input/output
error - failed to read
bin  boot  core  data  dev  etc  home  lib  lib64  media  mnt  opt  proc
 root  run  sbin  selinux  srv  sys  tmp  usr  var
root at ffmpeg:/# exit

[1]+  Stopped                 lxc-execute -n ffmpeg -- bash
A ~ # fg
lxc-execute -n ffmpeg -- bash

(note that I needed to run "fg" at the end to get lxc-execute to stop
completely at the end).

-- 
Fajar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20130915/fd5c9017/attachment.html>


More information about the lxc-users mailing list