Prepare one agent outside the workload
Use a dedicated vault with only the items this workload needs. Provision a separate agent for each workload. Keep managing keys and connect tokens outside the running agent. The connection script writesagent.env and two trust files beside it. agent.env holds the agent’s credential and proxy settings, not your stored upstream keys. It has mode 0600. The file contains absolute certificate paths, so preserve those paths when you mount it into a container.
The bundle keeps public roots in place because a tool that reads those settings trusts only that file. Over an
https proxy URL it must also trust the gateway’s own certificate. The script stops if it finds no system roots, so install ca-certificates in the image first.
After a successful request, git passes the proxy credential to its
credential helper. On macOS with
osxkeychain, the agent’s credential can
end up in the login keychain. It stops working once you disconnect the
agent, and it is never an upstream secret. To keep it out, run
git config --global credential.helper "" in the agent’s environment.onecli tokens create --vault <vault>. Download the connection script from your instance’s /v1/install/connect endpoint and inspect it. Then run it with the token, with ONECLI_HOME set to this directory and ONECLI_PROFILE set to "$CONFIG_DIR/profile". Those variables keep its files and shell-profile change in the directory you chose. Add --name research-worker to give the new agent a recognizable name.
You can instead provision an agent with an explicit expiry in trusted automation and run the script with --credential to install that agent’s credential. Don’t put either credential in an image build argument, Dockerfile, service unit, shared terminal transcript, or source control.
Docker: use an isolated gateway network
This example requires Docker Engine and nftables on a Linux host. It uses a self-hosted Compose gateway namedonecli-gateway. It gives the agent an internal network whose only other container is the gateway. It does not connect the API, database, or dashboard to that network. Don’t apply it unchanged to Docker Desktop, where the bridge lives inside a separate VM.
Before starting, build your own research-agent:3.0 image. It must contain /bin/sh, curl, a CA trust bundle, and your agent executable at /opt/agent/bin/run. The name is an example for your local image, not a OneCLI release image. Use a non-root UID and no setuid tools. Pick an unused subnet if 172.30.40.0/24 overlaps your host or VPN.
1
Connect only the gateway to the agent network
Run these commands as the trusted Docker operator:The gateway retains its existing service network for upstream access. Reapply this extra network attachment if Compose recreates the gateway container. Stop the workload until its network path is restored.
2
Block access to the bridge host
An internal Docker network is not a firewall for services listening on the host’s bridge address. Add this separate nftables table on the Docker host before starting the agent:Save it as Persist this table with your host firewall. It blocks connections from the agent bridge to the host, not requests forwarded between the agent and gateway containers.
/etc/nftables.d/onecli-agent-host.nft. Apply it as the host operator:3
Check the generated proxy destination
On the setup host, check the endpoint without printing the credential:For this recipe, your instance must advertise
gateway:10255 as ONECLI_AGENT_PROXY_ADDRESS when you provision the agent. Don’t rewrite a credential-bearing URL by pasting it into a shell history.4
Start the workload without host privileges
Create a workspace containing only the files the agent may change. Run from its parent directory:Keep Docker’s default seccomp profile. Don’t add
--privileged, host networking, extra networks, devices, or a Docker socket mount. The explicit host entry lets the proxy resolve without giving the agent an external DNS resolver. The gateway resolves upstream names.The read-only config mount contains a credential for this agent. Never replace it with the instance .env, your home directory, or the gateway data volume.Linux: use a dedicated account and outbound firewall
Use a dedicated unprivileged account, not your personal login. Give it a private home, nosudo access, and no supplementary groups that control containers or the host. Install the agent and its connection files as that account. Keep the gateway on a protected, reachable private address.
This example assumes the account has UID 20000 and the gateway is 10.20.0.10:10255. Replace those with your assigned UID and private address. Add a root-owned host entry for the proxy name, for example 10.20.0.10 gateway, so this account needs no outbound DNS. Provision it with that proxy address before applying the firewall.
Restrict outbound connections
Apply a dedicated nftables table as root on the Linux agent host. It only narrows the dedicated account’s outbound traffic. It does not replace your existing firewall. Don’t apply it on the gateway host using the gateway service’s UID./etc/nftables.d/onecli-agent.nft. Check syntax before applying it:
Restrict the service
Run the workload under a systemd service with a small writable state directory. For example, use/var/lib/research-agent as the account’s home and provision its files at /var/lib/research-agent/.config/onecli. The account and directory must exist before you start the service.
/etc/systemd/system/research-agent.service. Confirm that research-agent really has UID 20000, matching the firewall rule. Validate the unit before starting it:
Test the boundary
Run these checks inside the same container or service context as the agent, before replacing a test workload with the real one:
Use explicit connection timeouts for network checks. Test again after a reboot or container recreation. If direct egress succeeds, stop the workload and fix the network boundary. Proxy variables alone are not a safe fallback.