fix(docker): persistent container + exec pattern#41
Merged
KailasMahavarkar merged 2 commits intomainfrom Apr 10, 2026
Merged
Conversation
Previous docker run --rm pattern spawned a new container for every claude CLI invocation. Combined with the server not exiting on stdin close, this left orphaned containers running across sessions. Fix: - install.md Option A now documents a persistent `hyperstack-mcp` container started once with `sleep infinity` as PID 1, and each MCP session `docker exec`s a fresh bun process into it. One container total, zero per-invocation container startup cost. - src/index.ts now handles stdin close / SIGTERM / SIGINT to exit cleanly when the client disconnects, preventing zombie bun processes inside the persistent container. - Troubleshooting section adds a cleanup command for users migrating from the legacy docker run --rm config. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Triggers rebuild of ghcr.io image with stdin close handler fix. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
KailasMahavarkar
added a commit
that referenced
this pull request
Apr 14, 2026
fix(docker): persistent container + exec pattern
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.
Summary
docker run --rmper session → persistenthyperstack-mcpcontainer +docker execper sessionsrc/index.tsso bun exits cleanly when the client disconnectsWhy
Previous pattern spawned a new container for every
claudeinvocation. Combined with missing stdin lifecycle handling, orphaned containers piled up over multiple sessions.New pattern
# One-time setup docker run -d --name hyperstack-mcp --restart unless-stopped \ --memory=512m --cpus=1 \ --entrypoint sleep \ ghcr.io/orkait/hyperstack:main infinity{ "mcpServers": { "hyperstack": { "command": "docker", "args": ["exec", "-i", "hyperstack-mcp", "bun", "/app/src/index.ts"] } } }One container. All sessions
execinto it. Zero per-invocation container cost.Validated
docker exec -i hyperstack-mcp bun /app/src/index.tslocally → MCP init response returned correctly🤖 Generated with Claude Code