r/PiCodingAgent • • 8h ago

Resource One-time podman containers for Pi

Hey guys becaues Pi documentation advises to use containers for Pi usage I created a simple bash script as a center command for my workflow and figured out I'd share here - https://github.com/intpl/sandpi It basically mounts current directory in a disposable container (will destroy after exiting the Pi process), also binds the Pi config directory as read-write, also binds user ~/.agents directory read-only. I use Linux on desktop and servers so this workflow is great for me - I just run around my filesystem running `sandpi` everywhere. Maybe somebody wants to reuse or share a better solution. I created a simple blogpost and recorded a video of me talking as an explanation of why and how - https://gladecki.pl/technical/sandpi/
It happened to me many times before than the agent was doing weird stuff with my system (with OpenCode and omp too) and that's why i created this.

A friend of mine suggested I should have used Nvidia OpenShell but that's an absolute overkill imo.

Btw are there any humans on Reddit anymore?

7 Upvotes

5 comments sorted by

2

u/suprjami 6h ago edited 5h ago

I do something extremely similar.

I map the non-root user in the container to my current UID so permissions on new workspace files are sensible:

OPTS+=( "--userns=keep-id:uid=1000,gid=1000" )

I set .git read only if it exists:

if [ -d "${WORKSPACE_DIR}/.git" ]; then
    OPTS+=( "--volume" "${WORKSPACE_DIR}/.git:/workspace/.git:ro" )
fi

I agree OpenShell and many others are too complex for their own good. The only thing I want is a permission prompt on all network access, so I can verify every web fetch or package install or exfiltration from programming language compiler/interpreter, and otherwise the agent can run in permission-free yolo mode because there's nothing it can actually ruin.

Basically I want OpenSnitch as a Pi prompt. I don't know how to achieve this.

Edit: Hmm, maybe I could run opensnitchd inside the container, and have Pi write a TypeScript plugin which registers to that daemon and acts as the OpenSnitch user prompt with the usual Pi permission UI...

1

u/intpl 41m ago

hey that's a good idea with opensnitchd and plugins but this will show you everything going on and ask about every small thing. maybe some sort of a plugin with tcpdump to monitor what's going on and then act according to it's own judgement to kill the process or whatnot? i mean in the end if you are in the loop you will get annoyed if asked about every network call.

3

u/architized89 8h ago

I tried docker sbx but that needs a docker login from time to time. Because I’m running almost local only that annoyed me. I settled on microsandbox. That has worked well for me so far.

2

u/fell_ware_1990 7h ago

May i suggest:

Seccomp
--cap-drop=all
no-new-privileges
Landlock

You can add them all easily to the container if you like.

RO on .git and .jj hooks can be done.

What i did for this, only a RW on the jj workspace. Which my system handles and before merge we lint it :)

1

u/SlanderMans 7h ago

Am human, can I recommend that you try out smolvm?

I am the maintainer and is designed for lightweight sandboxing: https://github.com/smol-machines/smolvm