The Docker project
Offline Bash and file calls in fresh containers, a persistent volume, and optional web lookups outside the container.
Developer runs a test and leaves a file called status.txt. Its next command can open the file, even though the container that wrote it is gone. Follow the file and you can see the two lifetimes at work in a Docker projectPipal’s project backend that runs commands and file operations in temporary Docker containers with a shared named volume.. The command gets a container for the length of the call. The project gets storage it can come back to.
In this chapter
- Follow one Bash command from approval to cleanup.
- Locate the files that survive and the scratch files that disappear.
- See how a file edit and an optional Git clone reach the volume.
- Read the isolation settings and tell what Pipal checks when it opens the location.
The volume carries files from one container to the next
In Three ways to touch a project you saw how the operator describes the Docker destination in [extensions.project_shell]. Set the image and volume there and include pipal.coding for file tools and pipal.bash for commands in an explicit extensions.enabled list. Restart Pipal, then enable the locationThe place a chat uses for project tools, either the Pipal host, an account reached over SSH, or a Docker project. in Settings → Workspace and use Docker in a new Developer chat. On upgrade, Pipal imports the configured grant if durable.sqlite already exists and there is no saved workspace settings file. config.ts workspace-locations.ts
Give Pipal the name of a prepared Linux image and a named Docker volumeA folder managed by Docker whose files can outlive the containers that use it., storage managed by Docker. The image supplies the starting filesystem and needs /bin/bash for Bash calls, Node.js for file operations, and GNU /usr/bin/timeout for both. The volume needs to be writable by container UID and GID 1000:1000. The Docker CLI runs on the Pipal host, while the selected engine runs the containers and stores the volume. The engine may be on a separate machine. It mounts the volume at /workspace for ordinary operations. deployment.md project-shell.ts
Deep diveOpening the location pins the image and checks the named volume
loadWorkspaceLocations probes the Docker location as it opens, including at startup if it is enabled or when you enable it in Settings. A failed probe leaves a new enable request unsaved. Fix the cause and click Save changes with Docker selected again. If a configured location fails its startup probe, it stays selected and Settings shows the backend error with a Retry connection button. workspace-locations.ts DeveloperWorkspace.svelte
createProjectTools asks in parallel for the engine’s CPU count, the volume’s description, and the image’s OS and ID. The image must report Linux and a sha256: image ID. The volume must match the configured name, have a local driver and local scope, have no driver options, and report a nonempty creation timestamp. Pipal takes the SHA-256 hash of the JSON array [imageId, volume, createdAt] as a hex string for the workspace scope used when matching approvals. Enabling clones appends git_clone to that array. Approvals and YOLO follows that match. project-shell.ts index.ts
Before every container creation, run rechecks the volume timestamp. Recreating the volume makes that check fail if the timestamp changed. Rebuilding an image tag leaves the backend using the old image ID, and creation fails if that image has been removed. To use the replacement, disable the location and save, then enable it and save again to run a new probe. Start a new chat to bind to the new identity. project-shell.ts workspace-locations.ts index.ts
Before the first create, Pipal checks the volume and removes leftover containers with the same pipal.project=<volume> label. The runtime already holds the store lock, so a second Pipal process opening the same store cannot run that cleanup. The lock covers the store, while the cleanup label identifies containers by volume name on the engine. Pipal attempts docker rm --force --volumes in finally, even after Stop or failure. Any error from that removal marks the location to sweep again before the next create, including an error because --rm has already removed the container. project-shell.ts index.ts
For a Docker chat from before the upgrade, pinnedScope uses a saved project scope or falls back to the chat’s YOLO scope. If neither was saved, it uses legacyDockerScope, the identity recorded when the migrated Docker location first opens successfully. boundWorkspace requires that identity to match the open location. An old chat therefore keeps its binding when the location is reopened with the same identity, and loses project access if that identity changes. workspace-locations.ts index.ts
One Bash call gets one container
The Docker entry in Settings → Workspace and the Runtime panel for a Docker chat show “Shell commands run without network access.” Ordinary file operations use the same offline container setup. workspace-choice.ts project-shell.ts
- Chat
- Pipal
- Docker
- Bash
- Volume
Chat → Pipal · Approve
You let the command run
Developer has requested
printf "ready\n" > status.txt; cat status.txt. The approval lets Pipal execute that Bash call.Pipal → Pipal · Route Bash
Pipal checks the chat’s binding
Core checks the chat’s location and project scope. The host router checks the binding again and calls the Docker implementation of Bash.
Pipal → Pipal · Wait for turn
The call requests the volume lock
Pipal checks the requested starting directory first. Then the call waits for earlier calls using this open Docker location.
Pipal → Docker · Inspect volume
Pipal verifies the volume still matches
It compares the creation timestamp with the value recorded when the location opened. If it matches, Pipal sweeps labeled leftovers before the first create.
Pipal → Docker · Create
Docker prepares an offline container
The container uses the pinned image and sees the volume at
/workspace. Docker creates it with--network=none. The command starts in the next step.Pipal → Docker · Start + attach
Pipal starts the container and watches its output
The Docker client stays attached. Inside the container, GNU
timeoutstarts Bash and Bash enters the requested directory.Bash → Volume · Write file
Bash writes to the volume
With no
working_diroverride, the relative pathstatus.txtlands at/workspace/status.txt.Docker → Pipal · Output
Pipal streams the tool output
The attached client carries the output of
catback to Pipal. The tool’s output window retains the tail.Docker → Pipal · Exit status
The Docker client returns the exit code
Pipal checks for cancellation and timeout before returning the status from the container run.
Pipal → Docker · Clean up
Pipal attempts forced removal before releasing the lock
Docker can have already removed the container on exit. The named volume still holds
status.txt.Pipal → Chat · Result
The chat receives the result
The successful call reports exit code 0. With
pipal.coding, a laterpublish_filecall can attachstatus.txtfrom the volume to this chat.
Chat → Pipal
You let the command run
Developer has requested printf "ready\n" > status.txt; cat status.txt. The approval lets Pipal execute that Bash call.
After approval, Pipal routes the call to the location’s Bash tool, which checks where the command should start and requests the volume lock. exclusive uses locks.request from node:worker_threads with a name for this open backend. Calls run one at a time in the order they reach the lock. If you press Stop while your call waits, its abort signal takes it out of line and earlier calls can finish. workspace-locations.ts project-shell.ts
Docker prepares the container with docker create. Pipal then asks Docker to start the container and attach to it, which means the client stays connected to the command’s output. The transcript shows output as it arrives and keeps the last part if the command prints more than fits. When a command finishes within its time allowance, Pipal reports its exit code, the number a program returns to say whether it succeeded. Pipal attempts cleanup before the next call can take its turn. project-shell.ts project-tool-definitions.ts
Suppose your next call runs a build and saves its output under /workspace/build. Open a new chat with the same Docker project and ask Developer to list that folder with Bash. Docker will start another container and attach the volume again. That call can see the build output. If the build wrote its cache under the container’s default home, it wrote to /tmp, and the new call starts with fresh temporary storage. project-shell.ts
File tools and Bash start from the image Pipal inspected, so changing the image tag alone does not change the programs the next call will find. project-shell.ts
Deep diveWhat Docker receives when Pipal creates the container
'create', '--name', name,
'--label', `${label}=${volume}`,
...(interactive ? ['--interactive'] : []),
'--rm', '--pull=never', '--init',
cloneStage ?
'--network=bridge' :
'--network=none',
'--read-only', '--user=1000:1000',
'--cap-drop=ALL', '--security-opt=no-new-privileges',
'--no-healthcheck', '--pids-limit=128',
'--memory=1g', `--cpus=${cpus}`, '--log-driver=none',
'--env=HOME=/tmp', '--tmpfs',
'/tmp:rw,nosuid,nodev,size=256m',
'--mount',
`type=volume,source=${volume},target=${workspace},volume-nocopy` +
(cloneStage ? `,volume-subpath=${cloneStage}` : ''),
'--workdir', cloneStage ? '/tmp' : workspace,
'--entrypoint',
'/usr/bin/timeout', imageId,
'--kill-after=2s', `${timeout}s`, ...command - Name this container
Pipal assigns a name with a random UUID to address the same container at start, clone mount inspection, and cleanup.
- Mark the project
The label
pipal.project=<volume>makes containers from earlier calls discoverable by the project cleanup. - Keep input open for helpers
An interactive helper can receive a JSON request on standard input. Ordinary Bash is started without interactive input.
- Remove on exit
Docker removes the stopped container. The named volume has its own lifetime.
- Use the image already present
Container creation cannot pull an image from a registry. Pipal supplies the ID it inspected when the location opened.
- Reap child processes
Docker puts an init process in the container to forward signals and collect exited children.
- Keep ordinary calls offline
Bash and file helpers get no network connection to the outside. Only the staged Git fetch uses Docker’s bridge network.
- Protect the image filesystem
Docker makes the image’s root filesystem read-only. The project mount and
/tmpare separate writable mounts. - Run as an ordinary user
The command runs as user and group ID 1000 inside the container. Provision the volume so that user can write to it.
- Drop Linux capabilities
Linux capabilities are individual privileges, such as the ability to mount filesystems. Docker drops all capabilities for this container.
- Block privilege gains on exec
A program the command launches cannot gain privilege through executable file settings such as setuid.
- Disable image health checks
Docker skips any health-check command baked into the image. The tool call controls the lifecycle.
- Cap process and thread count
The container’s PID limit is 128. A command cannot spawn processes and threads without a bound.
- Cap memory
Pipal requests a 1 GiB memory limit for the container.
- Cap CPU use
Pipal requests up to two CPUs, or the engine’s CPU count if lower. An invalid count yields a one-CPU limit.
- Skip Docker’s log store
Docker does not save logs through a log driver. Pipal captures output through the attached client.
- Give programs a temporary home
Software writing to
$HOMEgets the container’s temporary directory. Those files disappear with the container. - Allocate writable scratch space
The writable temporary filesystem has a 256 MiB size limit. It disallows setuid and setgid effects and use of device nodes from that mount.
- Attach the project files
Docker mounts the named volume at
/workspace.volume-nocopyprevents image files at that path from seeding a fresh volume. - Expose only the clone stage
The networked fetch sees only its fresh subdirectory at
/workspace. A normal operation sees the volume root. - Set the initial directory
The initial directory is
/workspacefor ordinary containers. Bash can change directory before running your command. The Git fetch starts in/tmpand clones into/workspace. - Start the timer before the command
GNU
timeoutreplaces the image entrypoint. The immutable image ID selects the filesystem the container starts with. - Limit the command’s lifetime
GNU
timeoutsendsSIGTERMwhen the requested number of seconds elapses, thenSIGKILLafter another two seconds if the command is still running.
'create', ,
,
,
, , ,
,
, ,
, ,
, ,
, , ,
,
,
+
,
,
,
, ...command 1 Name this container
Pipal assigns a name with a random UUID to address the same container at start, clone mount inspection, and cleanup.
The flags restrict commands inside the tool container. The Pipal service account itself runs the Docker client and can ask the engine to create other containers. On a rootful engine, one running with root privileges, that access is root-equivalent. The deployment guide recommends rootless Docker or a dedicated engine. The named volume also has no size limit set by Pipal, so its files can compete for disk space with chat storage when the two share a filesystem. server.md deployment.md
Deep diveHow Bash enters the directory and how Pipal recognizes a timeout
working_dir defaults to .. Pipal resolves it against /workspace and rejects a normalized path outside the project. Inside the container the prelude exits with code 2 if the path is missing or isn’t a directory. Otherwise it changes into it with cd -P, clears OLDPWD, then replaces itself with Bash so the command is interpreted by bash -c without profile or rc files. The requested path is checked lexically before the call. The prelude follows the physical directory when it changes into it, and the container supplies the filesystem boundary. project-shell.ts
const cwd = posix.resolve(workspace, working_dir);if (cwd.includes('\0') || (cwd !== workspace && !cwd.startsWith(workspace + '/'))) { throw new Error('Use a working directory inside /workspace.');}const args = ['/bin/bash', '--noprofile', '--norc', '-c', enter, 'bash', cwd, command];Bash accepts a timeout from 1 to 3,600 seconds and defaults to 60. The attached client uses the command allowance through withWorkspaceToolTime, with a client timeout three seconds longer than the command timeout. Queueing, volume checks, and docker create precede that allowance and count against the response deadline. Cleanup follows the attachment. Each Docker CLI management call has a 60-second timeout and a 1 MiB output buffer limit. project-tool-definitions.ts project-shell.ts index.ts
The elapsed-time check starts immediately before attachment, after creation and any mount check. Pipal checks for cancellation first, then reports a timeout if the attached client timed out, or if the client returned exit code 124 or 137 and at least the requested number of seconds elapsed. A command that exits before the deadline with 124 or 137 still reports that exit code. project-shell.ts project-shell.test.ts
Pipal forwards output text and the skipped-output count from the attached client through api.output. The shared bashDefinition sets retain: 'tail'. For a completed command, Pipal returns an exit diagnostic and marks nonzero exits as errors. Timeouts use the separate error above. project-shell.ts project-tool-definitions.ts
Pi asks a file helper to work inside the container
When Developer calls edit, Pi’s tool works out the text change. To get or save the bytes, it uses a small set of operations Pipal supplies. Each operation starts Node.js inside a container and sends the helper a JSON request on standard input, the stream of data into the program. An edit can read in one container and write in another. Pipal holds the volume lock for the whole edit so a second tool call cannot slip between those operations. project-coding.ts project-shell.ts
Ask Developer to attach the saved status.txt and it can call publish_file with that relative path. After approval or a matching YOLO grant, the tool reads the file under the volume lock in a fresh offline container. Pipal saves the bytes with the chat and serves the download from its store. Files in, artifacts out follows the copy after it leaves the volume. project-shell.ts project-coding.ts
Deep diveWhat travels to the Node.js file helper
projectCoding gives Pi’s read, edit, and write an environment backed by a per-call cache and the backend’s file operations. For Docker, Pipal converts a path to one relative to /workspace, sends JSON to project-files.mjs, and waits for JSON back. The Docker adapter rejects blank paths, NUL bytes, and paths over 4 KiB at its boundary. The worker accepts up to 1 MiB of input JSON. It checks the normalized path, rejects the project root, paths outside it, and any .git component, then checks that existing parents are directories and existing targets are single-link regular files. A symlink fails those checks. Reads and writes carry bytes in base64. The text reader Pipal supplies for edits rejects invalid UTF-8 and NUL bytes, while Pi’s read can also receive binary data. project-coding.ts project-shell.ts project-files.mjs
Each file operation gets 15 seconds inside the container and an 18-second host attachment timeout. The Docker adapter ends the attached client’s stdin after sending the request and returns its output on a zero exit code. The shared projectCoding adapter checks the 512 KiB write limit before sending the request and parses the helper’s JSON reply. It turns a missing file into a FileError with code not_found. project-shell.ts project-coding.ts
The worker pins each parent as its working directory before resolving the next component. After changing directory, it checks the device and inode against the directory it inspected. A read opens the target with O_NOFOLLOW and checks the open file again. It fails if the byte count differs from the initial size or if a second check detects a size or change-time difference. project-files.mjs
For a write, the worker creates missing parents and stages a file with mode 0600 beside the destination. When replacing an existing regular file, it copies the file’s 0777 permission bits before renaming the staged file into place. project-files.mjs
const stage = await mkdtemp('.pipal-write-');try { const file = join(stage, 'file'); await writeFile(file, bytes, { mode: 0o600 }); const previous = await lstat(target).catch(error => { if (error.code !== 'ENOENT') throw error; }); if (previous) { requireRegularFile(previous); await chmod(file, previous.mode & 0o777); } await rename(file, target);} finally { await rm(stage, { recursive: true, force: true }); }Developer can look up docs from a Docker chat
Developer requests two independent, opt-in grants. In extensions.enabled, keep the project bundles and add pipal.web-search for provider-hosted search on supported models, pipal.public-web for the host’s search and page-reading tools, or both. Restart Pipal to apply the change. config.example.toml main.ts
Developer’s instructions favor provider search. For a fallback search, search_public_web sends the query from the Pipal host to Exa. For a specific page, read_url sends a public HTTPS URL to Jina Reader. Both tools return text to the chat. The project container keeps its offline network setting throughout. developer.md public-web.ts
A clone gets a network connection and a smaller mount
- Pipal
- Helper
- Git
- Volume
- Docker
Pipal → Pipal · Route clone
Pipal checks the approved call’s binding
The host router uses the location and project scope checked by core. The call goes to the Docker implementation of
git_clone.Pipal → Pipal · Validate
Check the URL and folder name
The URL must be HTTP(S) without credentials, query, or fragment. Pipal also rejects whitespace and backslashes in the URL. The destination must be a single new directory name.
Pipal → Pipal · Wait for turn
The clone requests the volume lock
Pipal holds the lock through staging, fetching, and publishing or cleanup.
Pipal → Docker · Prepare
Start an offline helper
Pipal asks Docker to run the helper. It checks that the destination is free and creates a fresh
.pipal-clone-…directory with mode0700at the root of the volume.Helper → Volume · Create stage
The empty stage is ready to mount
The offline helper sees the full volume so it can check the destination and create the temporary directory.
Pipal → Docker · Create
Docker prepares the networked container
Pipal requests bridge networking and mounts the fresh stage at
/workspaceusingvolume-subpath.Pipal → Docker · Verify subpath
Check the mount recorded by Docker
Pipal reads the first mount’s
VolumeOptions.Subpathfrom the container configuration. A mismatch stops the fetch before start.Pipal → Docker · Start + attach
The Git fetch gets its own network connection
Docker starts Git’s container and the client stays attached. Git runs with fixed arguments and a cleared environment. Its
/workspaceis the stage.Git → Volume · Write checkout
Git fills the staging directory
The fetch updates the stage while Pipal streams progress. The publish helper will check the chosen destination again.
Docker → Pipal · Exit status
The exit status decides the next offline action
Pipal attempts to remove the networked container before proceeding. Success leads to publish. A fetch or publish failure leads to an offline discard attempt before the lock is released.
Pipal → Docker · Publish
Publish only a successful checkout
Docker starts a fresh offline helper to check the destination again. If it is still free, the helper renames the stage into place.
Helper → Volume · Rename stage
The checkout now has its final path
The next Bash or file call can use the finished checkout at
/workspace/<folder>and still runs offline.
Pipal → Pipal
Pipal checks the approved call’s binding
The host router uses the location and project scope checked by core. The call goes to the Docker implementation of git_clone.
To bring a checkout into the volume, opt into allow_git_clone = true with pipal.bash. Cloning is off by default. Give Developer an HTTP(S) repository URL the engine can reach without credentials and an unused folder name. The Git container sees only the fresh staging directory from the project volume. Once Git succeeds, a separate offline operation renames the stage to the destination. Bash and the file tools continue to work offline. project-tool-definitions.ts project-shell.ts
Deep diveHow Pipal limits what the networked fetch can see
The image needs Git for the fetch and Node.js for the staging helpers. The clone requires Docker CLI and Engine support for volume subpaths, which Pipal’s error message identifies as version 26 or newer. Pipal checks the subpath recorded in Docker’s container configuration before start, since an engine can ignore an unfamiliar field. Git runs with a cleared environment and a fixed argument list. An HTTPS URL allows only HTTPS, while an HTTP URL allows HTTP and HTTPS. The command disables system and global Git configuration, hooks, templates, and terminal credential prompts. The fetch gets 3,600 seconds, with the same three-second host attachment margin as Bash. project-shell.ts
The clone holds the volume lock across prepare, fetch and publish. The offline helper checks the destination at prepare and again at publish. It refuses a destination it finds occupied. Prepare, publish, and discard each use a fresh offline container with a 60-second command timeout and a 63-second attachment timeout. After a successful prepare, a failed fetch or publish triggers recursive removal of the stage in a discard call without the cancelled call’s abort signal. A failed discard can leave a stage behind and surface its own error. Prepare runs before that recovery path begins. clone-stage.mjs project-shell.ts
If you need npm install or another command to download packages from a registry, start a new chat on This machine or SSH machine and work on a checkout there. For a build in the Docker project, supply the dependencies ahead of time in the image or volume. The development workspace follows Bash and file helpers in a persistent project folder, where you can also start a service that outlives the call. project-shell.ts developer.md
Recap
- Docker creates a fresh container for each Bash call or file operation. The named volume at
/workspacekeeps saved files. - The volume lock orders access across chats sharing the open location. Commands stream output and release their turn after the cleanup attempt.
- Optional Git clones fetch with only a staging directory mounted, then publish to the volume offline.
- One Bash call saves a report in /workspace and a cache in /tmp. What can the next container read?
- Both files
- The report in /workspace
- The cache in /tmp
Answer and explanation
The report in /workspace
Docker attaches the same named volume to the next container. The temporary filesystem belongs to the call that created it.
- A test program prints a message and the attached client returns code 124 long before the deadline. What does the Bash tool report?
- Exit code 124
- A timed-out project command
- Success because the command finished early
Answer and explanation
Exit code 124
Pipal uses the elapsed time as well as the code to recognize GNU timeout exits. It reports the early 124 as a nonzero exit.
- git_clone reports success. Where can the next offline Bash call find the repository?
- Only in the Git container’s memory
- In the Pipal chat database
- Under the chosen folder name in /workspace
Answer and explanation
Under the chosen folder name in /workspace
Git fills a staging directory in the volume. An offline helper renames it to the destination before the clone tool returns. Bash still runs offline when it opens the checkout.
One Bash call saves a report in /workspace and a cache in /tmp. What can the next container read?
A test program prints a message and the attached client returns code 124 long before the deadline. What does the Bash tool report?
git_clone reports success. Where can the next offline Bash call find the repository?