undockit
undockit.args
Argument parsing for undockit CLI
add_install_parser
def add_install_parser(subparsers)
Add the install subcommand parser
add_build_parser
def add_build_parser(subparsers)
Add the build subcommand parser
add_run_parser
def add_run_parser(subparsers)
Add the run subcommand parser
get_parser
def get_parser()
Create the argument parser for undockit
undockit.__version__
undockit.__main__
Main entry point when running undockit as a module
undockit.backend.base
Abstract base class for container backends
Backend Objects
class Backend(ABC)
Abstract base class for container runtime backends
build
@abstractmethod
def build(dockerfile_path: Path) -> str
Build image from dockerfile and return image ID
Arguments:
dockerfile_path
- Path to the dockerfile to build
Returns:
Image ID/hash that can be used to reference the built image
Raises:
RuntimeError
- If build fails
command
@abstractmethod
def command(image_id: str) -> list[str]
Extract default command from image
Arguments:
image_id
- Image ID returned from build()
Returns:
List of command arguments (ENTRYPOINT + CMD combined)
start
@abstractmethod
def start(container_name: str, image_id: str, timeout: int = 600) -> None
Start a warm container
Arguments:
container_name
- Unique name for the containerimage_id
- Image ID to runtimeout
- Seconds of inactivity before container shuts down
stop
@abstractmethod
def stop(container_name: str) -> None
Stop and remove a container
Arguments:
container_name
- Name of container to stop
is_running
@abstractmethod
def is_running(container_name: str) -> bool
Check if a container is currently running
Arguments:
container_name
- Name of container to check
Returns:
True if container is running, False otherwise
exec
@abstractmethod
def exec(container_name: str, argv: list[str]) -> int
Execute a command in the container
Arguments:
container_name
- Name of running containerargv
- Command and arguments to execute
Returns:
Exit code from the executed command
name
@abstractmethod
def name(image_id: str) -> str
Get container name for an image ID
Arguments:
image_id
- Image ID returned from build()
Returns:
Container name to use for this image
undockit.backend.podman
Podman backend implementation
PodmanBackend Objects
class PodmanBackend(Backend)
build
def build(dockerfile_path: Path) -> str
Build image from dockerfile using podman build
command
def command(image_id: str) -> list[str]
Extract default command from image using podman inspect
start
def start(container_name: str, image_id: str, timeout: int = 600) -> None
Start a warm container with host integration and timeout management
stop
def stop(container_name: str) -> None
Stop and remove container
is_running
def is_running(container_name: str) -> bool
Check if container is currently running
exec
def exec(container_name: str, argv: list[str]) -> int
Execute command in container with proper workdir
name
def name(image_id: str) -> str
Get container name for an image ID
undockit.backend
Backend system for undockit - manages container runtimes
get_backend
def get_backend() -> Backend
Auto-detect and return the best available backend
undockit.install
Tool installation functionality for undockit
resolve_target_path
def resolve_target_path(to: str,
env: Dict[str, str],
sys_prefix: str,
base_prefix: str,
prefix: Optional[Path] = None) -> Path
Return the directory where tool should be installed (pure logic)
extract_name
def extract_name(image: str) -> str
Extract tool name from image string
make_dockerfile
def make_dockerfile(image: str, timeout: int = 600) -> str
Generate wrapper dockerfile with shebang
resolve_target
def resolve_target(to: str = "user", prefix: Optional[Path] = None) -> Path
Wrapper that calls resolve_target_path with actual system values
install
def install(image: str,
to: str = "user",
name: Optional[str] = None,
prefix: Optional[Path] = None,
timeout: int = 600,
no_undockit: bool = False) -> Path
Install tool to target directory
undockit.main
Main entry point for undockit CLI
main
def main()
Main entry point for undockit CLI
undockit.deploy
Binary deployment for undockit - installs the undockit zipapp to target directory
get_installed_version
def get_installed_version(binary_path: Path) -> Optional[str]
Get version of installed undockit binary, or None if not installed
needs_update
def needs_update(binary_path: Path, current_version: str) -> bool
Check if binary needs updating based on version
create_zipapp
def create_zipapp(source_dir: Path,
output_path: Path,
main_module: str = "undockit.main:main",
python_shebang: str = "/usr/bin/env python3") -> None
Create a zipapp from source directory
Arguments:
source_dir
- Directory containing the package sourceoutput_path
- Where to write the zipappmain_module
- Entry point in module:function formatpython_shebang
- Shebang line for the zipapp
find_package_source
def find_package_source() -> Path
Find the source directory of the undockit package
ensure_binary
def ensure_binary(target_dir: Path,
binary_name: str = "undockit",
force: bool = False) -> Optional[Path]
Ensure undockit binary is deployed to target directory
Arguments:
target_dir
- Directory to install binary tobinary_name
- Name for the binary (default: undockit)force
- Force reinstall even if up to date
Returns:
Path to installed binary, or None if skipped