Development tools for quicksand - build custom VM images from Dockerfiles
Project description
Quicksand Image Tools
This package provides development tools for building custom VM images for the quicksand agent harness.
Installation
pip install quick-sandbox
quicksand install dev
CLI Usage
The recommended way to build custom images:
# Initialize a build directory (creates Dockerfile, builds base image if needed)
quicksand-image-tools init ./my-image ubuntu # or: alpine
# Customize the generated Dockerfile, then build the VM image
quicksand-image-tools build-image ./my-image/Dockerfile -o my-image.qcow2
Example Dockerfile
After running quicksand-image-tools init ./my-image ubuntu, a Dockerfile is created with the versioned base image. Add your customizations:
FROM quicksand/ubuntu-base:24.04.0
# Add your customizations here
RUN apt-get update && apt-get install -y nodejs && rm -rf /var/lib/apt/lists/*
The base images include the kernel, agent, and init configuration. You just add your packages.
Python API
Build a VM image programmatically:
import asyncio
from quicksand_image_tools import build_image
from quicksand import Sandbox, SandboxConfig
async def main():
# Build from a Dockerfile path
image_path = build_image("./Dockerfile")
# Use the custom image
async with Sandbox(SandboxConfig(image_path=str(image_path))) as sb:
result = await sb.execute("node --version")
print(result.stdout)
asyncio.run(main())
Dockerfile Requirements
When building FROM a base image (quicksand/ubuntu-base or quicksand/alpine-base), you just add your packages - the base handles everything else.
For scratch Dockerfiles, you must:
- Install a kernel: Ubuntu
linux-image-virtualor Alpinelinux-virt - Build the Rust agent via multi-stage Docker build
- Configure a systemd service or OpenRC script to run the agent on boot
See the examples/custom_image.py for a complete working example.
CLI Reference
quicksand-image-tools init [directory] [ubuntu|alpine]
Initialize a directory for building custom images.
- If no Dockerfile exists in the directory, you must specify a base image type (
ubuntuoralpine) - Automatically builds the base Docker image if it doesn't exist
- Creates a Dockerfile with the appropriate
FROMstatement
quicksand-image-tools build-base [ubuntu|alpine|all]
Build base Docker images locally. Creates versioned images (e.g., quicksand/ubuntu-base:24.04.0) and tags them as latest. The version matches the installed quicksand-ubuntu or quicksand-alpine package version.
quicksand-image-tools build-image <dockerfile> [-o output] [--cache-dir dir]
Build a VM image from a Dockerfile.
Python API Reference
build_image(dockerfile, output_path=None, cache_dir=None)
Build a VM image from a Dockerfile.
dockerfile: Path to a Dockerfileoutput_path: Where to save the qcow2 image (default: cached by hash)cache_dir: Cache directory (default:~/.cache/quicksand/images/)
Returns the Path to the built qcow2 image.
get_agent_source_dir()
Returns the Path to the Rust agent source directory (quicksand-guest-agent/). This is used by image packages to set up symlinks for Docker builds.
How It Works
- Builds a Docker image from your Dockerfile
- Creates a container and exports its filesystem
- Extracts kernel and initrd from
/boot - Converts the filesystem to a bootable qcow2 VM image
Requirements
- Docker must be installed and running
- QEMU tools (bundled with quicksand-core, or install separately)
License
MIT
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 Distributions
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 quicksand_image_tools-0.5.8-py3-none-any.whl.
File metadata
- Download URL: quicksand_image_tools-0.5.8-py3-none-any.whl
- Upload date:
- Size: 28.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.10 {"installer":{"name":"uv","version":"0.11.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57120df8f19121d597d96bbb9d331dc5a29880d4f102552f9e04bfdee0fe1c60
|
|
| MD5 |
4ae3f516cb6ebe18720bc48f5653b765
|
|
| BLAKE2b-256 |
5952f9c597bc7cbd563df4ce03cbb284c78e7ee13e373d010d969dc33974d59a
|