Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A short introduction to LXC

7090d58d804c96911a37c84e4e90a9cf?s=47 Ranjib Dey
February 21, 2014

A short introduction to LXC

A short introduction to LXC, an user space implementation of container on mainline linux, and the ecosystem around it


Ranjib Dey

February 21, 2014


  1. A short introduction to LXC Ranjib Dey System Administrator, Bay

    Area Large-Scale Production Engineering – 02/20/2014
  2. Containers - Light weight virtualization - software based virtualization -

    userspace entity in mainline linux kernel (lxc) - built using kernel's containment facility
  3. Kernel facilities - namespaces - cgroups - capabilities

  4. Parts of a LXC container - rootfs - config -

    fstab - liblxc (dependency)
  5. Managing containers - create, destroy - start, stop (shutdown/kill, reboot)

    - freeze, unfreeze
  6. Customizing containers - template specific customizations - general configurations -

    cgroup related configurations - hooks - snapshots, overlayfs backed workflows - lxc-download pulls stock rootfs (CI backed)
  7. LXC packaging - liblxc is all you need to run

    - lxc-template offers linux distros - lxc all the binaries, stock configs
  8. Extending lxc - use template & download to build them

    - use config api to add run time configuration - build additional tools using any of the bindings - bindings: python, lua, ruby, Go.
  9. Extending lxc - simple example: #!/usr/bin/python3 import lxc container =

    lxc.Container("my_container") container.create("ubuntu", {"release": "precise"}) container.start() print(container.get_ips(timeout=10)) container.shutdown(timeout=10) container.destroy()
  10. Extending lxc - more complex example: #!/usr/bin/ruby require 'chef/lxc' lxc

    "web" do template "ubuntu" recipe do package "apache2" service "apache2" do action [:start, :enable] end end action [:create, :start] end
  11. Whats next? - lxc 1.0 released today - better user

    namespace support - tools for extensible storage - union file system(aufs, overlayfs) - s3, gfs, swift/glance etc - CRIU & pr.haul - Docker, Maestro, Deis, Hroot etc
  12. Thank You @RanjibDey