[Lxc-users] Creating stand alone container

Papp Tamas tompos at martos.bme.hu
Wed Feb 15 11:03:17 UTC 2012

On 02/15/2012 11:51 AM, bruce bushby wrote:
> Hi
> I've been following these two guides:
> https://access.redhat.com/kb/docs/DOC-67682
> http://berrange.com/posts/2011/09/27/getting-started-with-lxc-using-libvirt/
> and I finally have a container running (Happy Days)  I wanted to ask
> the list if anybody has experience with a "stand alone" container?
> My physical box is an HP running RHEL 6.2. I would like my container
> to have it's own rpmdb, root filesystem and OS commands etc. The
> container should be 100% separate from the physical BUT will run the
> exact same OS as the physical.
> I'm guessing I need to do something like:
> 1. create path for container ie "/virtuals/<container_name>"
> 2. Add filesystem path to container xml
> 2. copy entire OS from physical into "/virtuals/<container_name>"
> 3. Add network config to container xml
> 4. Start container?
> The above links give a busybox example, however I need the exact OS
> (development testing environment)
> As always, any help would be much appreciated!

You can copy a physical system.

Or you can follow something similar to this:

# must be absolute path!

mkdir -p $ROOTFS/var/lib/rpm
rpm --root=$ROOTFS --import 
rpm --root=$ROOTFS -ivh centos-release-6-2.el6.centos.7.x86_64.rpm
yum --installroot=$ROOTFS groupinstall Base

# or you cannot use rpmdb
cp -f $ROOTFS/root/.rpmdb/* $ROOTFS/var/lib/rpm

chroot .... rpm --rebuilddb

sed -i 's@/sbin/start_udev@#/sbin/start_udev@' /etc/rc.sysinit
sed -i "s at ACTIVE_CONSOLES=.*@ACTIVE_CONSOLES=/dev/console@"  

This worked for me. I run IPA in the container.
The host is Ubuntu.


More information about the lxc-users mailing list