Skip to main content

A small wrapper for creating LXD system containers for development purposes.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dev_lxc-0.3.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dev_lxc-0.3.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file dev_lxc-0.3.1.tar.gz.

File metadata

  • Download URL: dev_lxc-0.3.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for dev_lxc-0.3.1.tar.gz
Algorithm Hash digest
SHA256 df89fb11d7945efb9787c7dcd1aef4d742c55dca3c7c6c0cc46b8f32a8e7af2a
MD5 8efc70b23bca4b90029d44c454bd8c1d
BLAKE2b-256 0a58e30dc47bcfdfdfd53989978fb1b9b501344cfde36de791299bc5477873fc

See more details on using hashes here.

File details

Details for the file dev_lxc-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dev_lxc-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.3 Linux/6.8.0-49-generic

File hashes

Hashes for dev_lxc-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 73e9ecde42168c39045e54e29a669949ae454287183a78759e16823c044ac492
MD5 94bf5079c1ce4f9f2b19fd8205470137
BLAKE2b-256 ff8ecc96e95390c8119acecf9f2fe98630ab5b55328c2034f55856bbdc7f4f02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page