Skip to main content

run-isolated - run commands in an isolated environment, e.g. a Docker container

[Home | Download | sourcehut | PyPI | ReadTheDocs]

Overview

The run-isolated library allows programs to invoke some actions in an isolated, clean environment, with read-only or read/write access to existing filesystem directories.

It currently supports containers managed by the docker or podman command-line tools, and chroot containers managed by the schroot command-line tool.

Examples

Start a container with commands run as a non-root account by default, run a command as root, grab another command's output:

PATH_SRC: Final = pathlib.Path("/opt/src")
PATH_WORK: Final = pathlib.Path("/opt/work")

with rdocker.Container.start_container(
    run_isolated.Config(
        log=util.build_logger(name="ri-example", verbose=True),
        uid=1000,
        gid=1000,
    ),
    "debian:trixie",
    volumes=[
        rdocker.ContainerVolume(
            external=pathlib.Path.cwd(),
            internal=PATH_SRC,
            readonly=True,
        ),
        rdocker.ContainerVolume(
            external=pathlib.Path.cwd() / "work",
            internal=PATH_WORK,
            readonly=False,
        ),
    ],
) as cont:
    cont.run_command(["apt-get", "update"], ugid="0:0", cwd=pathlib.Path("/"))

    lines = cont.run_command_output(
        ["find", ".", "-mindepth", "1", "-maxdepth", "1", "-type", "f"],
    ).splitlines()

    cont.run_command(
        [
            "env",
            f"PYTHONPATH={PATH_SRC / 'src'}",
            "python3",
            "-B",
            "-u",
            "-m",
            "ri_example.worker",
            "-o",
            PATH_WORK,
        ],
    )

Contact

The run-isolated library was written by Peter Pentchev. It is developed in a sourcehut repository. This documentation is hosted at Ringlet with a copy at ReadTheDocs.

Metadata

Release files for run-isolated 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for run-isolated 0.1.3
File Size Uploaded Provenance Actions
run_isolated-0.1.3.tar.gz 75.0 kB Without provenance Details for run_isolated-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for run-isolated 0.1.3
File Interpreter ABI Platform Actions
run_isolated-0.1.3-py3-none-any.whl Python 3 none any Details for run_isolated-0.1.3-py3-none-any.whl

Total release size: 86.5 kB

Release files / run_isolated-0.1.3.tar.gz

Download URL run_isolated-0.1.3.tar.gz
Size 75.0 kB
Tags Source
SHA-256 checksum
How to use checksums
29fdcfa016a154a080d7bfb4e491970536a29b7e07648f30f4bc7059ec034d1f
BLAKE2b-256 checksum
How to use checksums
538baf7eeeab366e7c9a133752e38389dfa7ffe09f57becb1f4d67cf21c3093d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Release files / run_isolated-0.1.3-py3-none-any.whl

Download URL run_isolated-0.1.3-py3-none-any.whl
Size 11.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20b783b6be27ef8528b444eda121fb633c1ff0f30da395aeb5e46ed40efca7f4
BLAKE2b-256 checksum
How to use checksums
55fecde8927b2cdfa8b96e32b563d6c756bcb85852d9b4701133ea1c9f48eeed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.8

Security for run-isolated 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page