constrained-toolbox: Run isolated toolbox containers with podman

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Warnings:

This tool (originally based on the toolbox-constrained project) allows running isolated toolbox containers with podman. Mounting of home and host integration are not enabled by default, but one can choose to enable such capabilities specified in a toml configuration file.


[Skip to Readme]

Properties

Versions 0.1
Change log ChangeLog.md
Dependencies base (<5), containers, directory, extra, filepath, process, simple-cmd (>=0.2.3), simple-cmd-args (>=0.1.8), text, toml-reader, unix [details]
License Apache-2.0
Copyright 2026 Jens Petersen <juhpetersen@gmail.com>
Author Jens Petersen <juhpetersen@gmail.com>
Maintainer Jens Petersen <juhpetersen@gmail.com>
Category Utility
Home page https://github.com/juhp/constrained-toolbox
Bug tracker https://github.com/juhp/constrained-toolbox/issues
Source repo head: git clone https://github.com/juhp/constrained-toolbox.git
Uploaded by JensPetersen at 2026-07-07T12:38:17Z

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for constrained-toolbox-0.1

[back to package description]

constrained-toolbox

A Haskell rewrite of the fine toolbox-constrained tool.

Run a Toolbx image in an isolated podman container. Unlike toolbox enter, this does not bind-mount your home directory or integrate with the host by default. You explicitly choose what "capabilities" the container can access.

constrained-toolbox TOOLBOX [options] [CMD...]

The image is committed (saved) from the named toolbox container using buildah.

Examples

# Isolated shell, no host access
$ constrained-toolbox my-toolbox

# Mount current (project) directory in / and set it as the working directory
$ constrained-toolbox my-toolbox -p .

# Bind mount a volume
$ constrained-toolbox my-toolbox -v ~/data:/data

# Use capabilities from config
$ constrained-toolbox my-toolbox --cap ssh --cap git

# Read-only container filesystem
$ constrained-toolbox my-toolbox --readonly

# Remove the saved image after exit
$ constrained-toolbox my-toolbox --delete

# Set environment variables and prepend to PATH
$ constrained-toolbox my-toolbox -e MY_VAR=hello -P ~/.local/bin

# Run a specific command
$ constrained-toolbox my-toolbox -- ls /

# Dry run: print the podman command without running it
$ constrained-toolbox my-toolbox --dryrun

Usage

$ constrained-toolbox --version

0.1

$ constrained-toolbox --help

constrained-toolbox

Usage: constrained-toolbox [--version] [TOOLBOX]
                           [-v|--volume HOST:CONTAINER[:opts]]
                           [-e|--env KEY[=VALUE]] [-P|--path DIR]
                           [-i|--init CMD] [--cap NAME] [-p|--project DIR]
                           [--caps] [--readonly] [--dryrun] [--refresh]
                           [--delete] [CMD]

  Run a toolbox image in an isolated podman container

Available options:
  -h,--help                Show this help text
  --version                Show version
  -v,--volume HOST:CONTAINER[:opts]
                           Bind mounts (default to selinux :z)
  -e,--env KEY[=VALUE]     Set or pass through an environment variables
  -P,--path DIR            Prepend a directory to PATH inside the container
  -i,--init CMD            Run a bash snippet before entering the container
  --cap NAME               Enable a capability from the config file
  -p,--project DIR         Mount a project directory and set as workdir
  --caps                   List available capabilities from the config file
  --readonly               Make the container filesystem read-only
  --dryrun                 Print the podman command instead of running it
  --refresh                Force re-commit of the toolbox image
  --delete                 Remove the committed image after running

Capabilities

Define reusable groups of volumes, environment variables, PATH entries, and init commands in ~/.config/constrained-toolbox/config.toml:

[capabilities.ssh]
volumes = ["~/.ssh:~/.ssh:ro"]

[capabilities.git]
volumes = ["~/.gitconfig:ro"]

[capabilities.wayland]
env = ["WAYLAND_DISPLAY", "XDG_RUNTIME_DIR"]
volumes = ["$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY"]
security_opts = ["label=disable"]

[capabilities.rust]
path = ["~/.cargo/bin"]

Each capability can define:

~ and envvars are expanded in volume and path specs. If the host and container paths are the same, you can use the shorthand PATH[:opts] instead of PATH:PATH[:opts].

How it works

  1. Commits the named toolbox container to an image using buildah commit (reuses the existing image unless --refresh is passed)
  2. Runs podman run with --userns=keep-id so you are your own user, not root
  3. Sets up passwordless sudo inside the container
  4. Bind mounts get SELinux :z (shared) labels automatically, so multiple containers can safely access the same directories
  5. If --delete is used, the committed image is removed after exit

Building

cabal install

Requirements