Skip to content

fix(docker): insert --cidfile after run for docker.exe shell commands - #1773

Merged
Dumbris merged 3 commits into
smart-mcp-proxy:mainfrom
rudycelekli:fix/docker-exe-cidfile-20261023-01
Oct 30, 2026
Merged

Dumbris merged 3 commits into
smart-mcp-proxy:mainfrom
rudycelekli:fix/docker-exe-cidfile-20261023-01

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Problem

When the docker spawn keeps the login-shell wrap (non-Darwin without DOCKER_HOST/DOCKER_CONTEXT in the process env, which is the usual Windows case), insertCidfileIntoShellDockerCommand searches the command string for the literal docker run. On Windows the string begins with the resolved docker.exe path, often quoted ("C:\Program Files\Docker\resources\bin\docker.exe" run ...), so the search misses. The fallback then appends --cidfile <file> as extra shell argv. cmd.exe never passes that to docker, so no cidfile is written and the container can't be tracked for cleanup.

Fix

Read the first shell word (bare, path, or quoted), accept it when its base name is docker or docker.exe (case-insensitive), and insert --cidfile right after a following run verb. Commands that only mention docker run later in the string are no longer rewritten.

Test

TestInsertCidfile_DockerExe covers bare docker.exe, a quoted docker.exe path, plain docker, and a non-docker command. It fails on main and passes with this change. go test -count=1 ./internal/upstream/core/ passes.

Made with Cursor

@codecov-commenter

codecov-commenter commented Oct 24, 2026 •

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 82.75862% with 10 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
internal/upstream/core/connection_docker.go 82.75% 5 Missing and 5 partials ⚠️

📢 Thoughts on this report? Let us know!

On Windows without DOCKER_HOST the docker spawn keeps the shell wrap, and
the command string starts with the resolved docker.exe path. The literal
"docker run" search missed it, so --cidfile was appended as extra shell
argv where docker never saw it and the container could not be tracked
for cleanup. Match the first token as docker or docker.exe (bare, path,
or quoted) and insert --cidfile right after the run verb.
@rudycelekli
rudycelekli force-pushed the fix/docker-exe-cidfile-20261023-01 branch from e3518a8 to 7cb664f Compare October 24, 2026 22:18
Review finding on smart-mcp-proxy#1773: the cidfile path was spliced unquoted into the
string cmd.exe /c or bash -c re-parses. A %TEMP% with a space split the
path under cmd.exe and broke container start; under Git Bash the Windows
path lost its backslashes so the container ID was never tracked. Quote it
per shell dialect, keyed on the /c vs -c flag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@Dumbris Dumbris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: the bug reproduces on main and the PR fixes it. The review found one gap, closed by the maintainer commit on top (regression test included). Race tests and CI lint for the touched packages are clean on this branch merged with main, and the result was cross-reviewed clean.

# Conflicts:
#	internal/upstream/core/connection_docker.go
@Dumbris
Dumbris merged commit 7283605 into smart-mcp-proxy:main Oct 30, 2026
47 checks passed
@Dumbris

Dumbris commented Oct 30, 2026

Copy link
Copy Markdown
Member

Merged. Thank you, @rudycelekli! A shell-wrapped docker.exe run … command (or a quoted docker path) now gets --cidfile placed right after run, so the proxy can track and clean up the container instead of leaving it behind on Windows. I merged main into your branch to resolve the overlap with #1777 in connection_docker.go; both sets of helpers are kept.

Contributions like this are what keep MCPProxy moving, and they matter a lot to the project.

One small ask, only if you feel like it: a short public note about your change (a tweet, a LinkedIn post, a line in a community you are part of) helps more people discover MCPProxy. No pressure at all, and I would be glad to repost it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants