github / github/copilot-cli

Stdio Docker MCP containers remain running after closing a session

未关闭
#4,461 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

area:mcp area:sessions
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

Describe the bug

When multiple Copilot CLI sessions use local stdio MCP servers running in Docker, closing one session does not terminate the Docker containers started for that session.

The behavior occurs with both:

  • A direct Docker MCP.
  • A Node wrapper that starts.

Because both MCP implementations reproduce the problem, this appears to be a Copilot CLI stdio MCP lifecycle issue rather than a problem in either Docker image.

After using multiple sessions, docker ps showed three active instances of each image:

matheusrhgestor/html2pdf-mcp
matheusrhgestor/html2pdf-mcp
matheusrhgestor/html2pdf-mcp
matheusrhgestor/kendo-ui-doc
matheusrhgestor/kendo-ui-doc
matheusrhgestor/kendo-ui-doc

In one reproduction:

  • A session was resumed around 11:45 local time.
  • Its session shutdown was recorded around 11:54 local time.
  • The kendo-ui-doc and html2pdf-mcp containers created around 11:44 remained in Up state afterward.
  • A new active session started another pair around 11:55.

Representative container output:

052529bdf996|matheusrhgestor/html2pdf-mcp|Up 7 minutes
1793cf8f1aad|matheusrhgestor/kendo-ui-doc|Up 7 minutes
9870e1fd5c7f|matheusrhgestor/html2pdf-mcp|Up 18 minutes
d1bc7dd02cd6|matheusrhgestor/kendo-ui-doc|Up 18 minutes
e161b8af2fb7|matheusrhgestor/html2pdf-mcp|Up 39 minutes
fc11f628ff81|matheusrhgestor/kendo-ui-doc|Up 39 minutes
Affected version

1.0.79

Steps to reproduce the behavior
  1. Configure the kendo-ui-doc MCP as a local stdio server using Docker:

    {
      "type": "local",
      "command": "docker",
      "args": [
        "run",
        "--rm",
        "-i",
        "matheusrhgestor/kendo-ui-doc"
      ]
    }
    
  2. Configure the html2pdf MCP as a local stdio server using a Node wrapper that starts:

    docker run --rm -i --mount ... matheusrhgestor/html2pdf-mcp
    
  3. Start Copilot CLI session A and verify that one container per MCP is running.

  4. Start Copilot CLI session B and verify that a second pair of containers is running.

  5. Close session A using the normal session exit action, such as /exit or Ctrl+D.

  6. Run:

    docker ps --all --format "{{.ID}}|{{.Image}}|{{.Status}}|{{.Names}}|{{.CreatedAt}}"
    
  7. Observe that the containers created for session A are still running.

Image
Expected behavior

Closing a session should disconnect its stdio MCP processes and stop/remove only the containers created by that session.

The --rm option should remove each container after the corresponding docker run process is terminated.

Containers belonging to other active Copilot CLI sessions should remain running.

Additional context
  • Operating system: Windows 11 Pro
  • Architecture: x64
  • Shell: command prompt
  • MCP transport: local stdio
  • Docker images:
    • matheusrhgestor/kendo-ui-doc
    • matheusrhgestor/html2pdf-mcp

The direct kendo-ui-doc configuration uses docker run --rm -i.

The html2pdf wrapper uses Node child_process.spawn with stdio: "inherit" and also starts Docker with --rm -i. Therefore, --rm cannot clean up the container while the Docker process is still alive.

The issue is reproducible across more than one session and more than one MCP implementation. The likely failure is that closing a Copilot CLI session does not propagate termination to the local stdio MCP process and its Docker child process.

This appears related to:

https://github.com/github/copilot-cli/issues/4049
https://github.com/github/copilot-cli/issues/3440

This report concerns concurrent sessions and closing one session, rather than only /new or /resume.

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用通过 Docker 启动的本地 stdio MCP 命令,在两个 Copilot CLI 会话中复现该问题,然后跟踪这些子进程的会话关闭路径。完成的标准是:关闭一个会话时,仅终止并删除其 Docker 容器,而另一个活动会话的容器仍保持运行。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, node.js
领域
cli, devops
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。