From Fedora Project Wiki

Encapsule isolated devel containers

Summary

encapsule is a new small CLI tool for developers who want to try out "tools installed from the internet" for example (or use them within a project workdir) inside a safer container environment rather than directly in their home directory and host system.

Owner

Current status

Detailed Description

The CLI tool allows running developer containers, isolating your home directory and host from container side effects: it can "encapsule" a project and/or temp homedir there together with select enabled "capabilities". It uses Podman to run a (derived) container image (which can be generated by Buildah from a toolbox container say). The project readme file has more details about the specific features and commandline options.

In this age developers are frequently asked to install and run all kind of commands or software directly from the internet whether from source or more often now binaries. In recent years curl https://some.project/install.sh | bash or npm/npx install ... (and many others: pip, cargo, etc) are being normalized and can both pollute one's home directory or system, and also put it at increased security risk. encapsule provides a lightweight, somewhat safer environment for installing and running such tools. Note however it is not intended for running known malicious programs or security testing, etc - though at least it provides some basic separation or system hygiene. Users can also disable sudo or even the network (or potentially DNS) inside the encapsule container.

In many ways it makes opposite design choices to toolbox: closed by default rather than open - but one can opt in to sharing specific things from the host.

A lot of the original ideas are derived from toolbox-constrained by Sebastian Wick, without which this tool probably wouldn't exist now in its current form.

For more hardened isolation it is recommended to look at OpenShell though it is not available yet in Fedora. In the future it may be possible to migrate encapsule to wrap openshell for instance and use its gateway perhaps, which would enhance network isolation considerably.

The alternative is to use a VM of course, but that is much more heavyweight and awkward: though there is the similar whot/schupfn project, which allows exporting specified directories with 9p to a QEMU VM instance, also generated from a toolbox.

Feedback

Benefit to Fedora

Fedora users will have a simple way to isolate toolbox containers etc from their homedir and host system for running third party tools inside a contained environment, where they control what is shared from their home or host system.

Scope

  • Proposal owners:
    • Package review for encapsule (review bug) [done]
    • Build package and deps [done]
    • Fix reported issues and improve further
  • Other developers: N/A
  • Policies and guidelines: N/A (not needed for this Change)
  • Trademark approval: N/A (not needed for this Change)
  • Alignment with the Fedora Strategy:

Upgrade/compatibility impact

N/A

Early Testing (Optional)

https://copr.fedorainfracloud.org/coprs/petersen/encapsule/

How To Test

  • sudo dnf install encapsule
  • encapsule --help
  • encapsule run fedora:44 -p myproject
  • encapsule create fedora-toolbox:44 --home tmphome --cap wayland
  • encapsule run agent-harness --home agentic -p someproj
  • https://github.com/juhp/encapsule#examples

User Experience

Users will have a safer way to run harnesses and other tools grabbed from the internet.

Dependencies

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?) N/A (not a System Wide Change)
  • Contingency deadline: N/A (not a System Wide Change)
  • Blocks release? N/A (not a System Wide Change)


Documentation

<https://github.com/juhp/encapsule#readme>


Release Notes

The new encapsule tool allows running less trusted programs in restricted container environments on specific directories.