Spawn Docker on host when in Toolbox#106
Conversation
bbd42ae to
33aabce
Compare
Greptile SummaryThis PR adds a
Confidence Score: 4/5The change is isolated to a developer-only test helper script and does not touch any library, production, or CI code. It is safe to merge. The new docker() wrapper correctly uses command docker to bypass the function itself (avoiding infinite recursion), type -P to check for the binary on PATH (not the function), and a flatpak-spawn --host docker --version probe to guard the Toolbox path. The only drawback is that the --version probe fires on every docker invocation in the Toolbox environment rather than once, which is a minor inefficiency in a local test script. tests/local.sh — the only changed file; the per-call version probe is worth revisiting if the Toolbox path becomes frequently used. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[docker called with args] --> B{type -P docker\nbinary in PATH?}
B -- yes --> C[command docker args\nbypass function call binary]
B -- no --> D{command -v flatpak-spawn\navailable?}
D -- no --> E[echo to stderr Docker not available\nreturn 1]
D -- yes --> F{flatpak-spawn --host docker --version\ndocker on host?}
F -- no --> E
F -- yes --> G[flatpak-spawn --host docker args\nrun on host via Toolbox]
style C fill:#90EE90
style G fill:#90EE90
style E fill:#FFB6C1
Reviews (1): Last reviewed commit: "test(local): 🚨 spawn Docker on host whe..." | Re-trigger Greptile |
| docker() { | ||
| if type -P 'docker' >'/dev/null' 2>&1; then | ||
| command 'docker' "$@" | ||
| elif command -v 'flatpak-spawn' >'/dev/null' 2>&1 && flatpak-spawn --host 'docker' --version >'/dev/null' 2>&1; then |
There was a problem hiding this comment.
Extra host spawn on every Docker call in Toolbox
In the Toolbox/flatpak path, flatpak-spawn --host docker --version is executed as a probe on every single call to the docker() function — meaning each of the many docker run invocations in the suite spawns one extra process on the host just to re-confirm that Docker is available. Since the result can't change within a script run, this probe could be moved to a one-time check at script startup (e.g., cache the detected mode in a variable), avoiding the redundant roundtrip on each invocation.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
No description provided.