# node-lxd

> A client for LXD container virtualisation

Latest version **0.2.9** (published 2018-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-lxd
pnpm add node-lxd
yarn add node-lxd
bun add node-lxd
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.9 |
| Published | 2018-02-20 |
| First published | 2016-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 70.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 44 |
| Author | Alan Doherty |
| Maintainers | alandoherty |
| Keywords | lxd, lxc, container, virtualization, node-lxd, cgroups, os, linux, simple, sandbox, isolation, 2.0.0 |

## Links

- npm: https://www.npmjs.com/package/node-lxd
- Repository: https://github.com/alandoherty/node-lxd
- Homepage: https://github.com/alandoherty/node-lxd#readme
- Issues: https://github.com/alandoherty/node-lxd/issues
- npm.io page: https://npm.io/package/node-lxd

## Dependencies (2)

- [request](https://npm.io/package/request.md) 2.69.0
- [ws-unix](https://npm.io/package/ws-unix.md) 1.0.2

## Alternatives

- [angular-pipes](https://npm.io/package/angular-pipes.md) — 5.6K weekly downloads
- [@ng-web-apis/midi](https://npm.io/package/@ng-web-apis/midi.md) — 2.6K weekly downloads
- [happn-3](https://npm.io/package/happn-3.md) — 1.6K weekly downloads
- [@opensip-cli/lang-go](https://npm.io/package/@opensip-cli/lang-go.md) — 1.2K weekly downloads
- [mongoose-typescript](https://npm.io/package/mongoose-typescript.md) — 85 weekly downloads

## Recent versions

- 0.2.9 (latest) — 2018-02-20
- 0.2.8 — 2016-05-03
- 0.2.7 — 2016-03-23
- 0.2.6 — 2016-03-23
- 0.2.5 — 2016-03-23
- 0.2.4 — 2016-03-11
- 0.2.3 — 2016-03-10
- 0.2.2 — 2016-03-10
- 0.2.1 — 2016-03-04
- 0.2.0 — 2016-03-04
- 0.1.9 — 2016-02-29
- 0.1.8 — 2016-02-29
- 0.1.7 — 2016-02-28
- 0.1.6 — 2016-02-28
- 0.1.5 — 2016-02-28
- … 5 more at https://npm.io/package/node-lxd/versions

## README

[![npm version](https://badge.fury.io/js/node-lxd.svg)](https://badge.fury.io/js/node-lxd)

A client for communicating with a local or remote instance of linux containers. The interface is object-oriented, simple and uniform. Unrestrictive with an open MIT license.

# Installing

```bash
$ npm install --save node-lxd
```

## Getting Started ##

The following example connects to the local LXC instance and launches a new container.

```js
var lxd = require("node-lxd");

var client = lxd();

client.create("myContainer", "ubuntu", function(err, container) {
    container.start(function(err) {
        if (!err)
            console.log("Started " + container.name());
    });
});
```

## Example ##

The following example uses an express application to allow users to create containers and execute commands.

```js
// requires
var express = require("express");
var lxd = require("node-lxd");
var client = lxd();
var app = express();

var containers = {};

app.post("/create", function(req, res) {
	client.launch(req.query.name, function(err, container) {
		if (err) res.json({success: false, message: err.getMessage()});
		else {
			containers[req.query.name] = container;
			res.json({success: true, message: "Container launched"});
		}
	});
});

app.post("/run", function(req, res) {
	if (!containers.hasOwnProperty(req.query.name)) {
		res.json({success: false, message: "Container does not exist"});
		return;
	}

	containers[req.query.name].run(req.query.cmd.split(" "), function(err, stdOut, stdErr) {
		if (err) res.json({success: false, message: err.getMessage()});
		else if (stdErr.length > 0) res.json({success: false, message: stdErr});
		else {
			res.json({success: true, message: stdOut});
		}
	});
});

app.listen(3000, function(err) {
	if (!err)
		console.log("listening on port 3000");
});
```

## Documentation ##

The client class is documented [here](https://github.com/alandoherty/node-lxd/blob/master/docs/client.md).

The container class is documented [here](https://github.com/alandoherty/node-lxd/blob/master/docs/container.md).

The process class is documented [here](https://github.com/alandoherty/node-lxd/blob/master/docs/process.md).

---
_Source: https://npm.io/package/node-lxd · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
