Node native bindings to LXC inspired by: https://github.com/mcollina/lxc-native.
This is tested with Ubuntu Jammy with the following packages installed.
- build-essential
- lxc
- liblxc-dev
- nodejs (lts)
A Vagrantfile is provided to spin up a compatible environment using vagrant up
Ubuntu Jammy is recommended and you need the following packages
- lxc
- nodejs (lts)
// set name and lxc folder
const container = new LxcContainer({
name: "test",
lxcPath: "/var/lib/lxc",
});
// fill in rootfs and lxc config file from a template
await container.createFromTemplate({
distro: "ubuntu",
release: "focal",
arch: "arm64",
});
// start the container
await container.start();
// stop the container, time out after 30 seconds
await container.stop(30);
// destroy the container
await container.destory();
const containers = await LxcContainer.listContainers("/var/lib/lxc");
console.log(containers);
// list of names of the containers
const container = new LxcContainer({
name: "test",
lxcPath: "/var/lib/lxc",
});
const state = container.getState();
console.log(state);
// STOPPED, etc
- Can create containers
- Can start/stop containers
- Can destroy containers
- Can list containers
- Can get container state
- Can manage running container networks
- Can fetch container logs
- Can manage container snapshots
- Can execute commands inside container
- Simplified custom lxc configuration for volume bindings etc when not creating from template\