VPS Docker provider base classes for mngr
Project description
mngr VPS Docker Provider
Base classes and shared infrastructure for running mngr agents in Docker containers on VPS instances.
This package is a library -- it provides abstract base classes that concrete VPS provider implementations (like mngr_vultr) build on. It does not register any provider backends itself.
Architecture
Each VPS runs exactly one Docker container (1:1 mapping). Docker is used purely as a consistent provisioning mechanism. The VPS stays running at all times; stop/start operates on the container. Destroying the host destroys both the container and the VPS.
User Machine VPS
+------------------+ +-----------------------------------------+
| | SSH (port 22) | VPS OS (Debian/Ubuntu) |
| mngr CLI | ------------------> | (Docker commands over SSH) |
| | | Docker Engine (overlay2 on ext4 root) |
| ~/.mngr/ | SSH (port 2222) | +-----------------------------------+ |
| profile/ | ------------------> | | Container (sshd) | |
| providers/ | direct to | | /mngr -> /mngr-vol/host_dir | |
| <backend>/| VPS:2222 | +-----------------------------------+ |
| keys/ | | Docker named volume |
+------------------+ | (mngr-host-vol-<host_id_hex>) is a |
| bind-options local volume whose |
| device= points at: |
| /mngr-btrfs/<host_id_hex> |
| (per-host btrfs subvolume on a |
| loop-mounted /var/lib/mngr-btrfs.img) |
| host_state.json |
| agents/<agent_id>.json |
| host_dir/... |
+-----------------------------------------+
Key design decisions
- Docker commands over SSH: All Docker operations are executed via
ssh user@vps docker ..., not via the Docker SDK's remote host feature. - Direct SSH to container: The container's sshd port (default 2222) is exposed on the VPS's public IP. mngr connects directly to
<vps_ip>:2222with key-based authentication. - SSH host keys via cloud-init: Host keys are generated locally and injected into the VPS via cloud-init
user_data, eliminating TOFU (trust-on-first-use). - Per-host docker volume on a btrfs subvolume: Each VPS has exactly one mngr-managed Docker named volume (
mngr-host-vol-<host_id_hex>), created with--driver=local --opt type=none --opt device=/mngr-btrfs/<host_id_hex> --opt o=bind. Thedevice=path is a real btrfs subvolume on a loop-mounted btrfs filesystem (image file/var/lib/mngr-btrfs.img, mounted at/mngr-btrfsvia/etc/fstab), which makes the per-host data eligible forbtrfs subvolume snapshot -rfor consistent snapshots. mngr reads and writes metadata (host_state.json,agents/<agent_id>.json,host_dir/) directly on the subvolume by extractingOptions.devicefromdocker volume inspect. Docker itself keeps defaultdata-root=/var/lib/dockerandstorage-driver=overlay2(on the ext4 root); only this single volume's storage lives on btrfs. - Separate SSH keypairs: The VPS and container each have their own SSH keypair for defense in depth.
Modules
vps_client.py-- AbstractVpsClientInterfacethat concrete providers implement (create/destroy instances, snapshots, SSH key management)instance.py--VpsDockerProviderimplementation with full lifecycle (create, stop, start, destroy, snapshots, discovery)host_store.py--VpsDockerHostStorefor reading/writing host records on the unified per-host volume; constructed viaopen_host_store(outer, volume_name)cloud_init.py-- Cloud-init user_data generation for VPS provisioningconfig.py--VpsDockerProviderConfigbase configurationerrors.py-- Error hierarchy (VpsDockerError,VpsProvisioningError, etc.)primitives.py-- VPS-specific types (VpsInstanceId,VpsInstanceStatus, etc.)
Configuration
The base config (VpsDockerProviderConfig) provides these settings:
| Field | Default | Description |
|---|---|---|
host_dir |
/mngr |
Base directory for mngr data inside containers |
default_image |
debian:bookworm-slim |
Default Docker image |
default_idle_timeout |
800 | Idle timeout in seconds |
default_idle_mode |
IO |
Idle detection mode |
ssh_connect_timeout |
60.0 | SSH connection timeout in seconds |
vps_boot_timeout |
300.0 | VPS provisioning timeout in seconds |
docker_install_timeout |
300.0 | Docker installation timeout in seconds |
container_ssh_port |
2222 | Container sshd port exposed on VPS |
default_region |
ewr |
Default VPS region |
default_plan |
vc2-1c-1gb |
Default VPS plan |
default_os_id |
2136 | Default OS image (Debian 12 x64) |
default_start_args |
() |
Default docker run arguments |
btrfs_mount_path |
/mngr-btrfs |
Outer-host path where the loop-mounted btrfs filesystem holding the per-host unified volume is mounted |
btrfs_loop_file_path |
/var/lib/mngr-btrfs.img |
Outer-host path of the loop-backed btrfs image file (allocated with fallocate, persisted across reboots via /etc/fstab) |
outer_disk_reserved_gb |
20 |
GB of free space on the outer's root filesystem to reserve at provisioning time; loop file size is free_gb - outer_disk_reserved_gb |
Build and start args
Build args (-b) serve two purposes: VPS provisioning and Docker image building.
VPS-specific args use the --vps- prefix and are consumed by the provider:
--vps-region=ewr # VPS region
--vps-plan=vc2-2c-4gb # VPS plan (CPU/RAM)
--vps-os=2136 # VPS OS ID
All other build args are passed through to docker build on the VPS. This follows the same pattern as the Docker provider:
--file=Dockerfile # Use a specific Dockerfile
. # Build context (local directory, uploaded to VPS)
VPS provider implementations must not use any flags that conflict with Docker build flags. All VPS-specific flags must use the --vps- prefix.
Example: Create a host with a custom Dockerfile on a specific VPS plan:
mngr create my-agent --provider vultr -b --vps-plan=vc2-2c-4gb -b --file=Dockerfile -b .
Start args (-s) are passed to docker run:
--cpus=2 # CPU limit for container
--memory=4g # Memory limit
Host lifecycle
| Operation | What happens |
|---|---|
create |
Provision VPS, install Docker via cloud-init, prepare the btrfs loop filesystem on the outer (install btrfs-progs, fallocate + mkfs.btrfs the loop file, loop-mount it, persist via /etc/fstab, btrfs subvolume create the per-host subvolume), create the bind-options unified mngr-host-vol-<hex> volume pointing at that subvolume (seeded with empty host_dir/ and agents/), run container, set up SSH, write host_state.json |
stop |
docker stop the container. VPS keeps running. |
start |
docker start the container. Wait for SSH. |
destroy |
Remove container, best-effort btrfs subvolume delete of the per-host subvolume (drops host_state.json, agents/, and host_dir/ together), remove the docker named volume entry, destroy VPS (which also takes the loop file with it), clean up SSH keys |
| idle timeout | docker stop the container. VPS keeps running. |
Implementing a new VPS provider
To add support for a new VPS provider (e.g., DigitalOcean, Hetzner):
- Create a new package (e.g.,
mngr_digitalocean) - Implement
VpsClientInterfacewith the provider's API - Subclass
VpsDockerProviderand override_discover_host_records()and_find_host_record()to use the provider's instance listing API - Create a
ProviderBackendInterfaceimplementation and register via pluggy entry points
The btrfs loop-file setup is provided by the base class (_prepare_btrfs_on_outer, called at the top of _setup_container_on_vps); new providers do not need to install btrfs-progs or wire up the loop mount themselves as long as the outer host is a Debian-family Linux with apt-get available.
Compatibility
This release moves the per-host unified docker volume onto a loop-mounted btrfs filesystem (the volume itself becomes a bind-options local volume backed by <btrfs_mount_path>/<host_id_hex>). Existing vultr / ovh hosts created on the prior plain-docker-volume-create layout cannot be discovered or managed after upgrade. Destroy and recreate them. This is the same breaking-change shape as the earlier "two-volume consolidation" change.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imbue_mngr_vps_docker-0.1.4.tar.gz.
File metadata
- Download URL: imbue_mngr_vps_docker-0.1.4.tar.gz
- Upload date:
- Size: 67.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
96fb3653b448fbc30ff960b8061c88ebba776f7e677d06b6a80ea9744080ed03
|
|
| MD5 |
21ccb5ea172f752a85c0960fd40e9342
|
|
| BLAKE2b-256 |
09a456ad1c0ae8d176777e40265da5abcba56cf6e4ea395ff47df2f61c6fbca0
|
Provenance
The following attestation bundles were made for imbue_mngr_vps_docker-0.1.4.tar.gz:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imbue_mngr_vps_docker-0.1.4.tar.gz -
Subject digest:
96fb3653b448fbc30ff960b8061c88ebba776f7e677d06b6a80ea9744080ed03 - Sigstore transparency entry: 1737628085
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@7a619524959b403848caaad17cef1e66f8361b29 -
Branch / Tag:
refs/tags/v0.2.11 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a619524959b403848caaad17cef1e66f8361b29 -
Trigger Event:
push
-
Statement type:
File details
Details for the file imbue_mngr_vps_docker-0.1.4-py3-none-any.whl.
File metadata
- Download URL: imbue_mngr_vps_docker-0.1.4-py3-none-any.whl
- Upload date:
- Size: 46.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec360df358192a457fbc3a40e8cfc056217d08c8ff2eef3bdcfd8af44d084d0f
|
|
| MD5 |
062f3edae294934124a6f3f2a276c05e
|
|
| BLAKE2b-256 |
1d7d6f65358c86a9fceeb25e9f64a835fb2751cbbcbbdcfcc3fd9ac5f8607679
|
Provenance
The following attestation bundles were made for imbue_mngr_vps_docker-0.1.4-py3-none-any.whl:
Publisher:
publish.yml on imbue-ai/mngr
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
imbue_mngr_vps_docker-0.1.4-py3-none-any.whl -
Subject digest:
ec360df358192a457fbc3a40e8cfc056217d08c8ff2eef3bdcfd8af44d084d0f - Sigstore transparency entry: 1737629839
- Sigstore integration time:
-
Permalink:
imbue-ai/mngr@7a619524959b403848caaad17cef1e66f8361b29 -
Branch / Tag:
refs/tags/v0.2.11 - Owner: https://github.com/imbue-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7a619524959b403848caaad17cef1e66f8361b29 -
Trigger Event:
push
-
Statement type: