Update to libvirt-lxc driver doc page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here is a new drvlxc.html.in file to make the first example work.  I'll
play with the second example next.

thanks,
-serge

LXC container driver

The libvirt LXC driver manages "Linux Containers". Containers are sets of processes with private namespaces which can (but don't always) look like separate machines, but do not have their own OS. Here are two example configurations. The first is a very light-weight "application container" which does not have it's own root image. You would start it using

Example config version 1

<domain type='lxc'>
  <name>vm1</name>
  <memory>500000</memory>
  <os>
    <type>exe</type>
    <init>/bin/sh</init>
  </os>
  <vcpu>1</vcpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>LIBVIR_LXC_CMD</emulator>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <console type='pty' />
  </devices>
</domain>

In place of LIBVIR_LXC_CMD, use the result of the command

find /usr -name libvirt_lxc

The next example assumes there is a private root filesystem (perhaps hand-crafted using busybox, or installed from media, debootstrap, whatever) under /opt/vm-1-root:

<domain type='lxc'>
  <name>vm1</name>
  <memory>32768</memory>
  <os>
    <type>exe</type>
    <init>/init</init>
  </os>
  <vcpu>1</vcpu>
  <clock offset='utc'/>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <devices>
    <emulator>LIBVIR_LXC_CMD</emulator>
    <filesystem type='mount'>
      <source dir='/opt/vm-1-root'/>
      <target dir='/'/>
    </filesystem>
    <interface type='network'>
      <source network='default'/>
    </interface>
    <console type='pty' />
  </devices>
</domain>

In both cases, you can define and start a container using:

virsh --connect lxc:/// define v1.xml
virsh --connect lxc:/// start vm1
and then get a console using:
virsh --connect lxc:/// console vm1

Now doing 'ps -ef' will only show processes in the container, for instance. You can undefine it using

virsh --connect lxc:/// undefine vm1
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]