Repository navigation
fix(sandbox): pass args and stdin to Docker containers - #47
Merged
dwisiswant0 merged 2 commits intoNov 4, 2026
Merged
dwisiswant0 merged 2 commits into
dwisiswant0 merged 2 commits into
Conversation
EvalWithVirtualEnv with VirtualEnvDocker gave the container only the source text and an interpreter. The call args, Options.Args and the input source never reached it, so a script that Eval runs as "engine Options.Args script args < input" ran in Docker with no arguments, no interpreter flags and no stdin. SandboxDocker had no way to take them: RunSource accepted only the source and an interpreter, and the container was created without stdin. RunSourceWithOptions also takes interpreter args, script args and a stdin reader, and EvalWithVirtualEnv passes all three. The arguments reach the container as positional parameters of the wrapper shell, which execs "$@", so the shell never parses them. Stdin is attached before the container starts and closed once the input is copied. RunSource keeps its behavior, and a source with a shebang still runs directly, without the interpreter and its args. runCommand loses its unused createFile and fileContent parameters. Fixes: #46 Signed-off-by: Dwi Siswanto <git@dw1.io>
runCommand built the container and host configs, ran the container and read its logs in one function, and repeated the container removal on every exit path. The configs and the log reading move to containerConfig, hostConfig and collectResult, and one deferred call removes the container, so a new exit path can't skip the cleanup. The empty-command error becomes a sentinel, the environment slice is preallocated, and the log buffer size is a named constant. Behavior is unchanged. Signed-off-by: Dwi Siswanto <git@dw1.io>
Mzack9999
approved these changes
Nov 4, 2026
dwisiswant0
deleted the
dwisiswant0/fix/sandbox/pass-args-and-stdin-to-docker-containers
branch
November 4, 2026 08:54
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
EvalWithVirtualEnv with VirtualEnvDocker gave the container only the
source text and an interpreter. The call args, Options.Args and the
input source never reached it, so a script that Eval runs as "engine
Options.Args script args < input" ran in Docker with no arguments, no
interpreter flags and no stdin.
SandboxDocker.RunSourceWithOptions now takes interpreter args, script
args and a stdin reader, and EvalWithVirtualEnv passes all three. The
arguments reach the container as positional parameters of the wrapper
shell, which execs "$@", so the shell never parses them. Stdin is
attached before the container starts and closed once the input is
copied. RunSource keeps its behavior, and a source with a shebang still
runs directly.
A second commit splits runCommand into containerConfig, hostConfig and
collectResult, and removes the container with one deferred call instead
of a copy on every exit path. Behavior is unchanged.
The tests run the same source through Eval and through
EvalWithVirtualEnv against a stub Docker Engine API and compare the
output and exit code, so they don't need a daemon.
Fixes: #46