Skip to content

Docker containers not terminating properly when Claude Code disconnects #3

@jgbitz

Description

@jgbitz

Problem

When using the GitHub Chat MCP server in a Docker container with Claude Code, the containers do not terminate properly when Claude Code sessions end. This results in orphaned containers that accumulate over time.

Environment

  • MCP Server: github-chat-mcp (Docker container)
  • Client: Claude Code
  • Docker command: docker run --rm -i mcp/github-chat
  • Platform: macOS (Docker Desktop)

Expected Behavior

When Claude Code disconnects or terminates, the Docker container should receive a SIGTERM signal and shut down cleanly, allowing the --rm flag to remove the container.

Actual Behavior

Docker containers remain running after Claude Code sessions end. Multiple containers accumulate and must be manually stopped.

Comparison

Other MCP servers (playwright, wikipedia, etc.) using identical Docker run commands terminate correctly when Claude Code disconnects.

Evidence

$ docker ps --filter "ancestor=mcp/github-chat"
CONTAINER ID   IMAGE             COMMAND             CREATED          STATUS
c87ed0d7177c   mcp/github-chat   "github-chat-mcp"   5 minutes ago    Up 5 minutes
b98b4ebd8e85   mcp/github-chat   "github-chat-mcp"   6 minutes ago    Up 6 minutes
f43a1cd0c374   mcp/github-chat   "github-chat-mcp"   15 minutes ago   Up 15 minutes

Possible Cause

The FastMCP framework or the server implementation may not be properly handling SIGTERM signals for graceful shutdown.

Workaround

Manual cleanup: docker stop $(docker ps -q --filter "ancestor=mcp/github-chat")

Request

Could you investigate the signal handling in the MCP server implementation to ensure proper shutdown when receiving SIGTERM?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions