Repository navigation
Description
The code executor guide says:
"ContainerCodeExecutor starts a Docker container as a non-root user, with the network off and Linux capabilities dropped."
adk-python/docs/guides/code_executors/code_executor/index.md
Lines 199 to 201 in 12c7bed
| `ContainerCodeExecutor` starts a Docker container as a non-root user, with the | |
| network off and Linux capabilities dropped. If you are moving off | |
| `UnsafeLocalCodeExecutor`, this is the shortest step that puts a real boundary |
The network and capability hardening is there, but containers.run doesn't set user=, and neither do the exec_run calls:
adk-python/src/google/adk/code_executors/container_code_executor.py
Lines 329 to 340 in 12c7bed
| self._container = self._client.containers.run( | |
| image=self.image, | |
| detach=True, | |
| tty=True, | |
| # Harden the sandbox for untrusted, model-generated code: no network | |
| # (blocks metadata/SSRF/exfil), drop all Linux capabilities, and | |
| # forbid privilege escalation. Networking can be re-enabled via | |
| # `network_enabled=True` when the executed code is trusted. | |
| network_disabled=not self.network_enabled, | |
| cap_drop=['ALL'], | |
| security_opt=['no-new-privileges'], | |
| ) |
So the model's code runs as whatever user the image defaults to. For the image in the doc's own example (python:3.11-slim) that's root:
| image="python:3.11-slim", |
#6074 added the network and capability hardening; the user part seems to be the piece that didn't land. Maybe it's just the docs, but since this is described as the step that "puts a real boundary" between model code and the host, passing e.g. user="65534:65534" (or making it configurable) seems like the better fix than editing the sentence.
Found while testing a docs-vs-code checker I'm building (Elliot), then verified by hand.
Activity
Samecho commentedon Oct 24, 2026
May I send a small guide correction so it no longer promises a non-root user? The container and exec calls leave
userunset, so the guide should describe the image's configured user. I would leave runtime user selection separate, since forcing a UID could affect custom images.EmanueleCell4 commentedon Oct 24, 2026
docs: ContainerCodeExecutor runs as the image's user, not non-root
docs: ContainerCodeExecutor runs as the image's user, not non-root
Samecho commentedon Oct 25, 2026
I opened #7713 before your reply came through, so both PRs now cover the same paragraph. Sorry for the crossed wires. Would you prefer to continue with #7714? I want to avoid asking the team to review the same correction twice.
EmanueleCell4 commentedon Oct 25, 2026
Samecho commentedon Oct 26, 2026
Thanks, let's continue with #7714. I've closed #7713 so there's only one PR to review. I would appreciate the co-author credit. Please use
Co-authored-by: samecho <zhayutong@gmail.com>.docs: ContainerCodeExecutor runs as the image's user, not non-root
EmanueleCell4 commentedon Oct 26, 2026
Done, added you as co-author on #7714. Thanks!
sanketpatil06 commentedon Oct 27, 2026
Thanks, @EmanueleCell4 and @Samecho, for working this out together and combining it into one PR. We'll take #7714 forward and the team will review it shortly. If changes are needed, we'll leave feedback on the PR.
docs: say ContainerCodeExecutor runs as the image's user, not non-root