Skip to content

Wrapper around lxc utilities to make managing containers easier

Notifications You must be signed in to change notification settings

nigelmcnie/lxc-simple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Getting started with lxc

  1. Install dependencies

apt-get install lxc debootstrap libpasswd-unix-perl libfile-slurp-perl \
                libmoose-perl libpath-class-perl libconfig-inifiles-perl
  1. Set up networking

Your containers need a way to talk to the interweb. One way is a bridge.

A bridge is basically like a switch. You can plug your eth0 into it, and also each container. Then they can all talk to each other and the outside world.

Put something like this in /etc/network/interfaces:

auto lo
iface lo inet loopback

iface eth0 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports eth0
    bridge_stp off
    post-up /usr/sbin/brctl setfd br0 0

If you have a static lease, configure br0 with that information instead of the dhcp line::

iface br0 inet static
    address [your ip]
    netmask [your netmask]
    broadcast [your broadcast]
    gateway [your gateway]
    bridge_ports eth0
    bridge_stp off
    post-up /usr/sbin/brctl setfd br0 0
  1. Put info about networking setup in a file for later use

When containers are created, we need to tell them how to access the network. Put this in /etc/lxc/lxc.conf:

lxc.network.type=veth
lxc.network.link=br0
lxc.network.flags=up
  1. You're ready!

# Summary of commands
lxc --help

# Create a container called 'test'
lxc test create

# Start the container
lxc test start

# Enter it
lxc test enter

# Stop the container
lxc test stop

# Destroy it (you'll be asked to confirm)
lxc test destroy
  1. Starting containers automatically on boot

On ubuntu, install the upstart jobs:

cp upstart/lxc-* /etc/init

And when you create your containers, use -a to flag them as ones that should be automatically started on boot.

If you have a container you already made that you want to start on boot:

touch /var/lib/lxc/[name]/autostart

Good luck! -- Nigel McNie & Martyn Smith

About

Wrapper around lxc utilities to make managing containers easier

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages