Run commands in an isolated environment, e.g. a Docker container
Project description
run-isolated - run commands in an isolated environment, e.g. a Docker container
[Home | GitLab | 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.
Currently the only isolated environment supported is a Docker container.
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:bookworm",
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 GitLab repository.
This documentation is hosted at Ringlet with a copy at ReadTheDocs.
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 run_isolated-0.1.1.tar.gz.
File metadata
- Download URL: run_isolated-0.1.1.tar.gz
- Upload date:
- Size: 41.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d9acec176e34d9e3dcd299af0436c2a274284c1c4c7a281aed2f7a6dba6ef6b
|
|
| MD5 |
f3dafaa8e96a85b2330e7c8b64f25573
|
|
| BLAKE2b-256 |
d11592524ef8a4abdae97e980191aa1689a143a51c86aefa7e9bca93dc7403eb
|
File details
Details for the file run_isolated-0.1.1-py3-none-any.whl.
File metadata
- Download URL: run_isolated-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2f84cc1537ebbcb32ef1f90612cb4ec550ec656b05da77f093c9b368b6057253
|
|
| MD5 |
170978bfdf5c7ff108351ef3bdb88dbd
|
|
| BLAKE2b-256 |
ef242d70d9d0b57cb3793e86e74fb7a3067f73344efaaa0d79e02caf8eb086da
|