Skip to content

Spawn Docker on host when in Toolbox#106

Merged
zanbaldwin merged 1 commit into
6.xfrom
z/test-spawn-host
Jun 8, 2026
Merged

Spawn Docker on host when in Toolbox#106
zanbaldwin merged 1 commit into
6.xfrom
z/test-spawn-host

Conversation

@zanbaldwin

Copy link
Copy Markdown
Member

No description provided.

@zanbaldwin zanbaldwin self-assigned this Jun 4, 2026
@zanbaldwin zanbaldwin added the feature New feature (minor version bump) label Jun 7, 2026
@zanbaldwin zanbaldwin force-pushed the z/test-spawn-host branch from bbd42ae to 33aabce Compare June 8, 2026 08:48
@zanbaldwin zanbaldwin merged commit 9ad413d into 6.x Jun 8, 2026
24 checks passed
@zanbaldwin zanbaldwin deleted the z/test-spawn-host branch June 8, 2026 08:49
@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown

Greptile Summary

This PR adds a docker() shell function to tests/local.sh that wraps Docker invocations with a fallback for JetBrains Toolbox (Flatpak) environments, where the Docker binary is only available on the host via flatpak-spawn --host.

  • Adds a docker() wrapper function that checks for a local docker binary first, then falls back to flatpak-spawn --host docker if flatpak-spawn is available and host Docker responds to --version, and errors out otherwise.
  • All existing docker_composer and docker_php helpers transparently benefit from the wrapper since they already call docker by name.

Confidence Score: 4/5

The 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

Filename Overview
tests/local.sh Adds a docker() wrapper function with a flatpak-spawn fallback for Toolbox environments; logic is correct but runs an extra docker --version probe on every invocation in the Toolbox path.

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
Loading

Reviews (1): Last reviewed commit: "test(local): 🚨 spawn Docker on host whe..." | Re-trigger Greptile

Comment thread tests/local.sh
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature (minor version bump)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant