Struct buildchain::Lxc [] [src]

pub struct Lxc(_);

An LXC container

Methods

impl Lxc
[src]

Create a new LXC container

Arguments

  • name - The name of the container. This will be prepended with buildchain-
  • base - The base distribution to use, ubuntu:16.04 for example

Return

The newly created LXC container

Errors

Errors that are encountered while creating will be returned

Example

use buildchain::{Location, Lxc};

let mut lxc = Lxc::new(Location::Local, "test-new", "ubuntu:16.04").unwrap();

Run a command in an LXC container

Arguments

  • command - An array of command arguments

Return

And empty tuple on success

Errors

Errors that are encountered while executing will be returned

Example

use buildchain::{Location, Lxc};

let mut lxc = Lxc::new(Location::Local, "test-exec", "ubuntu:16.04").unwrap();
lxc.exec(&["echo", "hello"]).unwrap();

Mount a path in an LXC container

Arguments

  • name - The name of the mount
  • source - The source path to mount
  • dest - The destination of the mount

Return

And empty tuple on success

Errors

Errors that are encountered while mounting will be returned

Example

use buildchain::{Location, Lxc};

let mut lxc = Lxc::new(Location::Local, "test-mount", "ubuntu:16.04").unwrap();
lxc.mount("source", ".", "/root/source").unwrap();

Pull a file from the LXC container

Arguments

  • source - The source of the file in the container
  • dest - The destination of the file in the host

Return

And empty tuple on success

Errors

Errors that are encountered while mounting will be returned

Example

use buildchain::{Location, Lxc};

let mut lxc = Lxc::new(Location::Local, "test-pull", "ubuntu:16.04").unwrap();
lxc.pull("/etc/hostname", "target/hostname").unwrap();

Trait Implementations

impl Drop for Lxc
[src]

A method called when the value goes out of scope. Read more