Skip to content

Run a container and review an agent task

Choose what to verify first. The examples are independent and neither needs a model account.

  • Review staged edits offline: create two files with your local shell, review both, and write only one back to your project.
  • Container commands: pull an image, start a separate VM, execute commands, then stop and remove the container.

Container commands

New to pVisor on Apple Silicon? Run your first container before trying this walkthrough.

In a local terminal, install the CLI and complete VM platform setup. Linux x86_64 needs read/write access to /dev/kvm; Apple Silicon macOS needs a release package with the Hypervisor entitlement. No Docker Daemon or model account is needed, and this example mounts no host directory.

1. Prepare an image

pvisor pull alpine:3.20

Wait for the download to complete. First use needs registry access and enough cache space; later runs can reuse the cache. Resolve download failures by checking connectivity and disk space before starting a container.

2. Execute one command

pvisor run --rm --network none alpine:3.20 echo hello

Expect output containing hello. --network none disables guest networking; image download happens on the host. After exit, --rm removes this container while retaining the image cache.

3. Keep it running and execute tools

Choose an unused name. If pvisor-demo exists, replace it throughout the following commands:

pvisor run -d --name pvisor-demo --network none alpine:3.20 sleep 600
pvisor ps
pvisor exec pvisor-demo sh -c 'echo "inside the VM" > /tmp/result.txt'
pvisor exec pvisor-demo cat /tmp/result.txt

ps should list a running pvisor-demo; the last command should print inside the VM. Both exec calls use the same container. The file lives in the VM's /tmp, outside your current host directory. sleep 600 keeps it running for up to ten minutes; finish the remaining steps before it expires.

4. Stop and clean up

pvisor stop pvisor-demo
pvisor rm pvisor-demo
pvisor ps -a

The final list should no longer contain pvisor-demo. If ten minutes have elapsed and it has stopped, skip stop and run rm directly. Removal clears the container's writable layer, including /tmp/result.txt, while keeping cached images for reuse.

Problem Next action
KVM permissions or virtualization unavailable Check VM prerequisites; virtualized servers also need nested virtualization.
Image architecture mismatch Use a native-architecture image; CPU emulation is not provided.
Name already exists Inspect pvisor ps -a and choose another name; remove only containers you know belong to this demo.
exec cannot find a running instance Check status and name with pvisor ps -a, including whether the sleep deadline elapsed.

These commands manage a VM-backed container. See the container reference for flags and volume persistence. This demo configures no volumes and needs no Session review/apply/drop.

To run several services together, try experimental Compose.

Agent tasks

Use your local shell to create two candidate files and hand only the greeting back to the original directory. You are done when hello.txt is in the original directory and scratch.txt has been discarded. No model account, VM image, or running Daemon is needed. Run the steps in order in the same terminal and directory.

Before you start

If pvisor is not installed or Host staging is not set up, follow the Host staging prerequisites and return here. Linux x86_64 needs FUSE and user namespaces; Apple Silicon macOS needs macFUSE 5.4.0+ with FSKit enabled. Skip the VM prerequisites for this demo.

If you installed the CLI with pip, activate the virtual environment you used. With the dedicated environment in the installation guide, run:

source ~/.venvs/pvisor/bin/activate
pvisor --version

You should see a version number. Skip source for Homebrew or native packages. If the command is missing, follow the installation checks before continuing.

1. Create a demo directory

Open a terminal where you want to keep the demo files and create an empty directory:

mkdir pvisor-demo
cd pvisor-demo
pwd

Run the remaining commands here. If the directory exists, choose a new name so files from an earlier run do not affect the result. You do not need to clone pVisor or initialize Git.

2. Create files in a staged workspace

Run this command:

pvisor spawn --safe --overlaynet-deny-all -- sh -c '
  echo "Hello from pVisor" > hello.txt
  echo "Temporary notes" > scratch.txt
'

Wait for the command to finish and return to your terminal prompt. spawn starts and records a Session; --safe requests isolation and workspace staging; --overlaynet-deny-all disables networking for this offline task; everything after -- is the program and its arguments.

The command writes to files without printing their contents. Both files should remain staged. Check that neither appeared in the original directory:

test ! -e hello.txt && test ! -e scratch.txt && echo 'Workspace unchanged'

Expected output:

Workspace unchanged

If this line is absent, stop before applying anything. Check that the launch command included --safe, that the Session started successfully, and that you are in the right directory. For startup failures, see troubleshooting below.

3. Review the staged changes

Check the Session status and file diff:

pvisor status last
pvisor review last --diff

status should show a stopped task. review should list two additions, hello.txt and scratch.txt, containing Hello from pVisor and Temporary notes. Identities, paths, and timestamps vary between runs.

last selects the most recently registered Session for this workspace. Do not start another Session here until you finish the tutorial, because last would then select the new task. Use explicit Session identities for parallel work.

You can also read a file in the task's read-only view:

pvisor inspect last -- cat hello.txt

Expect Hello from pVisor. You can read the file inside the Session. In the original directory, cat hello.txt should still report a missing file.

Preview the selection before writing to the original directory:

pvisor apply last --path hello.txt --dry-run --diff

The preview should contain only hello.txt and leave both files staged.

4. Apply one file

Keep the greeting and leave the temporary notes out. Accept only hello.txt:

pvisor apply last --path hello.txt
cat hello.txt
test ! -e scratch.txt && echo 'scratch.txt: absent'

The output should include:

Hello from pVisor
scratch.txt: absent

hello.txt is now in the original directory; scratch.txt remains an unaccepted candidate. Stop other processes that might write the same files before applying. If an original file conflicts, apply refuses to overwrite it. Keep the stage and follow conflict handling before deciding what to do.

5. Discard the remaining change

Once you are sure you do not need the temporary notes, discard the remaining candidate:

pvisor drop last
cat hello.txt
test ! -e scratch.txt && echo 'scratch.txt: absent'

Expect the same two lines again. drop leaves the accepted hello.txt in place.

What happened?

Operation Files in the Session Files in the original directory
spawn --safe completes Both files are candidates Neither file exists
apply --path hello.txt completes Temporary notes still await a decision Only hello.txt
drop completes Remaining candidates discarded Still only hello.txt

File staging controls acceptance of file changes. drop does not undo accepted files or external API calls. Network and read restrictions depend on the executor and installed controls; see security boundaries.

Troubleshooting

Symptom Check and next action
pvisor: command not found Activate the installation environment or put the native package's bin on PATH; see installation checks.
FUSE, FSKit, or mount failure Complete platform setup. Check the device and mount helper on Linux or the filesystem extension on macOS.
setgroups, uid_map, or user namespace permission error Check system user namespace and AppArmor policies; see the Host executor.
last is missing or selects another task Return to the launch directory and use the recorded Session identity; see Sessions and storage.
apply refuses to run Check that the Session stopped, then inspect conflicts or incomplete records; see review and apply.

--safe refuses to start if required controls cannot be installed. Keep the flag while fixing setup: ordinary Host Sessions write directly to the original workspace by default.

Next steps

After the offline demo, connect the agent or script you already use. Try one small task in your own project: review the diff, then apply the files you want or discard the stage. Use the review and apply guide if you need to handle conflicts.

If you started with containers, try the VM tool execution example to collect structured results in a caller script. Look up flags, Session selection, and storage rules in the CLI reference.