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

A short introduction to LXC

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
Tweet

More Decks by Ranjib Dey

Other Decks in Technology

Transcript

  1. A short introduction to LXC
    Ranjib Dey
    System Administrator,
    Bay Area Large-Scale Production Engineering – 02/20/2014

    View Slide

  2. Containers
    - Light weight virtualization
    - software based virtualization
    - userspace entity in mainline linux kernel (lxc)
    - built using kernel's containment facility

    View Slide

  3. Kernel facilities
    - namespaces
    - cgroups
    - capabilities

    View Slide

  4. Parts of a LXC container
    - rootfs
    - config
    - fstab
    - liblxc (dependency)

    View Slide

  5. Managing containers
    - create, destroy
    - start, stop (shutdown/kill, reboot)
    - freeze, unfreeze

    View Slide

  6. Customizing containers
    - template specific customizations
    - general configurations
    - cgroup related configurations
    - hooks
    - snapshots, overlayfs backed workflows
    - lxc-download pulls stock rootfs (CI backed)

    View Slide

  7. LXC packaging
    - liblxc is all you need to run
    - lxc-template offers linux distros
    - lxc all the binaries, stock configs

    View Slide

  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.

    View Slide

  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()

    View Slide

  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

    View Slide

  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

    View Slide

  12. Thank You
    @RanjibDey

    View Slide