---
title: Introducing pylxd
description: In part of my work for nova-compute-lxd, we use a combination of httplib,
  UNIX domain sockets, and JSON to talk to the LXD daemon via the REST API. Talking
  to various people involved in the LXD project, I have decided to split this part
  of nova-compute-lxd into its own project called pylxd. Pylxd is a  […]
url: https://canonical.com/blog/introducing-pylxd
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Canonical](https://canonical.com/blog/author/canonical "More about Canonical")

27 May 2015

# Introducing pylxd

[containers](https://canonical.com/blog/tag/containers)
[docker](https://canonical.com/blog/tag/docker)
[LXC](https://canonical.com/blog/tag/lxc)
[LXD](https://canonical.com/blog/tag/lxd)
[OpenStack](https://canonical.com/blog/tag/openstack)
[Ubuntu](https://canonical.com/blog/tag/ubuntu)

---

Share the article

In part of my work for nova-compute-lxd, we use a combination of httplib, UNIX domain sockets, and JSON to talk to the LXD daemon via the REST API. Talking to various people involved in the LXD project, I have decided to split this part of nova-compute-lxd into its own project called pylxd. Pylxd is a general python library that you can use to interact with LXD in order to do container operations.

Right now, it is about 80% complete, the bits that are missing is that it needs more unit tests and needs more container operations (snapshots, running commands in the container, etc). That functionality will be coming in later releases of pylxd. I intend to use pylxd in the next version of nova-compute-lxd for the Liberty release of OpenStack as well. I am sure that there is other use cases that developers and users can use pylxd for.

To use pylxd, you just have to clone the git tree and build it. An example usage of pylxd is that you need a way to display the ‘/etc/hosts’ from your running ‘test1′ container. With pylxd this is pretty simple to do:

`#!/usr/bin/python`

from pylxd import api
c = api.API()
print c.get\_container\_file(‘test1′, ‘/etc/hosts’)

The result of the above snippet is that the ‘/etc/hosts’ from the ‘test1′ container will be displayed. Pretty simple eh?

The code for pylxd is [available on github](https://github.com/lxc/pylxd). Please report give it a twirl, please report bugs, and would love to get feedback.

### About the author

Chuck Short is a software engineer at Canonical. Originally from Vancouver but based in Ottawa, Chuck’s mission is to make sure OpenStack is a first class experience for both the X86 world and ARM world. You can follow his blog at [zulcss.wordpress.com](https://zulcss.wordpress.com/)

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

In submitting this form, I confirm that I have read and agree to
[Canonical's Privacy Notice](https://canonical.com/legal/data-privacy/contact)
and [Privacy Policy](https://canonical.com/legal/data-privacy).

Sign up

## Share on

---

## Related posts

[### Canonical announces the alpha release of Charmed OpenShell to help secure autonomous AI agent fleets](https://canonical.com/blog/charmed-openshell-alpha-release)

To streamline enterprise deployment and lifecycle management, Canonical is announcing the alpha release of Charmed OpenShell.

[Canonical](https://canonical.com/blog/author/canonical)

28 September 2026

[### Ubuntu coming soon to Snapdragon X2 Series platforms, unlocking more Linux PCs for the agentic world](https://canonical.com/blog/ubuntu-coming-soon-to-qualcomm-snapdragon-x2-series-platforms)

Canonical and Qualcomm Technologies announce upcoming native Ubuntu support for Qualcomm’s flagship laptop silicon, delivering multi-day battery life, 80 TOPS NPU acceleration,...

[Canonical](https://canonical.com/blog/author/canonical)

23 September 2026

[### Native Dell PowerStore integration lands in Canonical LXD](https://canonical.com/blog/lxd-powerstore-integration)

Canonical has broadened enterprise storage options for LXD by introducing a native driver for Dell PowerStore.

[Miona Aleksic](https://canonical.com/blog/author/mionaalex)

1 September 2026

[### Arduino® VENTUNO™ Q is available for pre-order with Ubuntu pre-installed](https://canonical.com/blog/arduino-ventuno-q-is-available-for-pre-order-with-ubuntu-pre-installed)

London, UK – August 25, 2026 – Following our initial collaboration announcement in March 2026, Canonical and Arduino (a subsidiary of Qualcomm Technologies, Inc.) are excited...

[Canonical](https://canonical.com/blog/author/canonical)

25 August 2026
