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.1.0.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

dev_lxc-0.1.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dev_lxc-0.1.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-45-generic

File hashes

Hashes for dev_lxc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1dd2aba76c7e77951a1d12715c50290a293f8b3b3e4ea4e28b40cdfe2fb9abcf
MD5 0abfdb418b2018ec9ed4396c37d778d1
BLAKE2b-256 dbbf296aa61b16863a6444026f8fcfbf7e8d9964644ebafe2df7ff6cc0ff7d6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dev_lxc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-45-generic

File hashes

Hashes for dev_lxc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71d0051c1854c3babbd5d167960238d2ec0588d571c55877603e6a4ec5a669b6
MD5 997182e154696b5a1299cb5bb9fc4f92
BLAKE2b-256 886b925e3f9b82838d8f143284a9bbdfd69e3de1dee396aae79b8202a528d608

See more details on using hashes here.

Supported by

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