Skip to main content

dev-lxc

This is a tidy little Python script I use when I want to quickly create an LXD system container for development purposes. It mounts the current directory in the home directory of the instance.

Installation

It's a single script file. Make sure you have LXD installed and Python 3.10 or higher. Get the file, make it executable, and put it on your PATH somewhere.

Basic Usage

Create an instance

Create an instance using a specific Ubuntu series, by codename:

dev_lxc create jammy

The instance name is generated from the current directory, so you can only have one instance of each series per directory. Names will clash.

If you have a valid YAML file for configuring the instance (nice for if you want it to start with certain packages installed):

dev_lxc create jammy --config ./my-config.yaml

Open a shell in an instance

Once you've created an instance, you can spin up a shell in it:

dev_lxc shell jammy

The default user (ubuntu) should be uid-mapped to your user, so file permissions should be okay.

Exec a command in an instance

dev_lxc exec jammy 'echo "hello"'

This executes using bash, so try not to get too fancy. You can also provide environment variables:

dev_lxc exec jammy 'echo "hello $MITCH"' --env MITCH="mitchell"

Stop or Start an instance

dev_lxc stop jammy

Stops the instance from running. Most other commands (shell, exec) should start the instance if it's stopped before running.

dev_lxc start jammy

Starts it up again.

Remove Instance

dev_lxc remove jammy

This deletes the instance. It is gone for good.

Release files for dev-lxc 0.4.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dev-lxc 0.4.4
File Size Uploaded
dev_lxc-0.4.4.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dev-lxc 0.4.4
File Interpreter ABI Platform
dev_lxc-0.4.4-py3-none-any.whl Python 3 none any Details

Total release size: 12.2 kB

Release files / dev_lxc-0.4.4.tar.gz

Download URL dev_lxc-0.4.4.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
a1f5fed485f9d7856502aa50fc41a3e8836fd8e03deb53871e66e40fe4184721
BLAKE2b-256 checksum
How to use checksums
6fce5df7881336eda7fbdd1e42cb7486fd75059ca9082b1e3a6c4de092a10257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.17.0-1011-oem

Release files / dev_lxc-0.4.4-py3-none-any.whl

Download URL dev_lxc-0.4.4-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
aab6c9ea5d265752f170375fec2029365a6cce688aee96fc5c8cb1ff566f3b65
BLAKE2b-256 checksum
How to use checksums
07fd3a51f09ad6f5a7472ccb6781363ca28ceb7a170f86d473aa8f793496100b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.1 CPython/3.12.3 Linux/6.17.0-1011-oem

Release history Release notifications | RSS feed

This release

0.4.4 This release

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page