[Lxc-users] newbie question: why all the lxc must be in /etc/lxc?

Ken Elkabany Ken at Elkabany.com
Tue Nov 6 19:00:11 UTC 2012


On Tue, Nov 6, 2012 at 5:28 AM, fpemud <fpemud at gmail.com> wrote:

> sorry I don't know if it is already been asked. (where to seach?)
>
> "lxc-create -n" creates new lxc in /etc/lxc, it's ok.
>
> but "lxc-start -n" also needs the lxc in /etc/lxc, it's too restrictive.
> I want to freely put my lxc in any directory of course.
>
> is there any technical reason? or is it a missing feature?
> is there any workaround?
>
>
There is no technical reason why the LXC containers must be in the same
directory; I'm guessing it was done for simplicity. To use an LXC container
that is scattered across the filesystem, just manually specify the location
of the config file:

$ lxc-start -n c-1 -f /mnt/containers/c-1-HkwdC/config -l DEBUG -o /mnt
/containers/c-1-HkwdC/container_log

Replace my paths (/mnt/containers/c-1-HkwdC) with yours. You'll need to
make sure that your config file also has the appropriate paths for the "lxc.
rootfs" and "lxc.mount" config variables.

Since we have a large LXC deployment, we actually resorted to specifying
the entirety of a container's configuration in the command line as follows
(truncated for brevity):

/usr/bin/lxc-start -n c-1 -f /dev/null -l DEBUG -o
/mnt/containers/c-1-HkwdC/container_log
-s lxc.rootfs=/mnt/containers/c-1-HkwdC/rootfs -s lxc.network.type=veth -s
lxc.network.link=lxcbr0 -s lxc.network.flags=up -s "lxc.mount.entry=proc
proc proc nodev,noexec,nosuid 0 0" -s "lxc.mount.entry=sysfs sys
sysfsdefaults 0 0" -s
lxc.arch=amd64 ...

Best,
Ken
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxcontainers.org/pipermail/lxc-users/attachments/20121106/776e54b0/attachment.html>


More information about the lxc-users mailing list