[Lxc-users] lxc template for RHEL?
Fajar A. Nugraha
list at fajar.net
Sat Aug 25 22:53:18 UTC 2012
On Sun, Aug 26, 2012 at 3:06 AM, Dan Kegel <dank at kegel.com> wrote:
> Trying the same thing with your centos template:
> cd /usr/lib/lxc/templates/
> wget https://raw.github.com/fajarnugraha/lxc/centos-template/templates/lxc-centos.in
> mv lxc-centos.in lxc-centos
> lxc-create -t centos -n democ6
> lxc-start -n democ6
> resulted in a session without working network.
What host are you using?
An ubuntu host will automatically add a networking section like this,
which works
lxc.network.type=veth
lxc.network.link=lxcbr0
lxc.network.flags=up
The default networking config section from lxc-fedora (upstream
version), when used in Ubuntu host would add an additional interface
in the container (because it's basically a separate, additional
networking section) and will result in "failed to rename
vethXXXXXX->eth0 : File exists" error, so I commented it out. Which is
why I'm surprised if you say lxc-fedora works for you, because its
default networking section should be the same (i.e. should also cause
"eth0: File exists" error).
> According to ifconfig inside the Centos session, eth0
> didn't have an ip address. I dimly recall that the network
> doesn't start by default on Centos desktops, so I did
> /etc/init.d/network start
> inside the centos session. That at least got eth0 an ip address,
Weird. I tested it on my ubuntu host, and guest container networking
is up automatically.
Try replacing your container config networking section (lxc.network.*)
with the ones from your working ubuntu container, or the one I pasted
earlier (i.e. you should NOT have any line that says "lxc.network.name
= eth0", only those three lines above for lxc.network.*).
> but dns still wasn't working. And it looks like part of the machinery
> is missing:
> # ls -l /etc/resolv.conf
> lrwxrwxrwx 1 root root 29 Mar 12 12:45 /etc/resolv.conf ->
> ../run/resolvconf/resolv.conf
> Adding a real file there made dns work, and I was able to do simple networking.
This one is partly my fault.
Ones a template is used, the resulting rootfs is cached on
/var/lib/lxc, and in the case of centos/fedora, it will be updated
(yum update) every time you use it to install new containers with that
template. Doing "yum --installroot" for update is bad, since the
host's yum version may do "bad stuff" (e.g. uses incompatible rpmdb
version), so I changed it to "chroot ... yum". However for that to
work, I need a working resolv.conf inside the rootfs, so I simply do a
"cp -a" from the host's resolv.conf, which works for me because I
uninstalled resolvconf. In your case it resulted in a non-working
resolv.conf :)
Since you already have a working /etc/resolv.conf (i.e. NOT a symlink)
inside the container, can you try rebooting the container? If it works
(i.e. got networking on boot), I can push a simple fix (which
basically would just change "cp -a" to just "cp").
--
Fajar
More information about the lxc-users
mailing list