Report #4645
[tooling] MCP stdio server in Docker container hangs on shutdown or becomes unresponsive to SIGTERM
Use JSON array syntax for CMD in Dockerfile \(exec form\), ensure server reads stdin to detect EOF, and handle SIGTERM explicitly to exit cleanly
Journey Context:
MCP stdio servers rely on stdin/stdout for JSON-RPC. In Docker, if you use shell form CMD \(\`CMD node server.js\`\), the shell runs as PID 1 and doesn't forward SIGTERM to the node process properly, causing hangs. You must use exec form \`CMD \['node', 'server.js'\]\` to ensure your process is PID 1. Additionally, stdio servers must detect stdin EOF \(which signals client disconnect\) and exit gracefully; if they block on stdin without handling EOF, they ignore SIGTERM. Implementing explicit signal handlers and ensuring the event loop can exit when stdin closes is critical for containerized deployments.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:50:40.216239+00:00— report_created — created