You need to enable JavaScript to run this app. MacOS VSCode运行QuantConnect Lean容器报55555端口占用报错
优惠活动
大模型
产品
解决方案
定价
更多

MacOS VSCode运行QuantConnect Lean容器报55555端口占用报错

MacOS环境下QuantConnect Lean容器Python开发端口绑定报错记录

报错触发场景

在MacOS系统下使用VSCode配置QuantConnect Lean量化引擎的Python开发环境,选择容器运行模式启动服务时,触发Docker端口绑定失败错误。
核心报错信息:

docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:55555: bind: address already in use.

带调试模式的容器启动完整日志

A Lean container is halted and will be removed. Continue? [y/n]: y
LeanEngine
Pulling Docker image: quantconnect/lean:latest
latest: Pulling from quantconnect/lean
Digest: sha256:ff6d17d055d27da2adcde8743628768880129ea68496e8b85a94d699543664db
Status: Image is up to date for quantconnect/lean:latest
docker.io/quantconnect/lean:latest
Launching LeanEngine with command: 
docker run --rm     --mount type=bind,source=/Users/odelibalta/Documents/Code/GitHub/Lean/Launcher/config.json,target=/Lean/Launcher/config.json,readonly     -v /Users/odelibalta/Documents/Code/GitHub/Lean/Data:/Data:ro     -v /Users/odelibalta/Documents/Code/GitHub/Lean/Results:/Results     --name LeanEngine     -p 5678:5678     --expose 6000 -v /Users/odelibalta/Documents/Code/GitHub/Lean/Algorithm.Python:/Lean/Algorithm.Python -p 55555:55555     --entrypoint mono     quantconnect/lean:latest --debug --debugger-agent=transport=dt_socket,server=y,address=0.0.0.0:55555,suspend=y     QuantConnect.Lean.Launcher.exe --data-folder /Data --results-destination-folder /Results --config /Lean/Launcher/config.json
docker: Error response from daemon: Ports are not available: listen tcp 0.0.0.0:55555: bind: address already in use.
ERRO[0000] error waiting for container: context canceled 

已完成的排查记录

  • 常规端口占用排查:执行sudo lsof -i:55555未返回任何占用该端口的进程信息;无论通过VSCode触发“在容器中运行”,还是通过Docker Desktop直接启动容器,都会复现同一端口报错
  • 容器残留状态排查:执行docker ps -a查看全量容器,仅存在一条状态为“Created”的残留LeanEngine容器记录,无其他运行中容器,查询结果如下:
    CONTAINER ID   IMAGE                      COMMAND                  CREATED              STATUS    PORTS     NAMES
    416ab7089c13   quantconnect/lean:latest   "mono --debug --debu…"   About a minute ago   Created             LeanEngine
    
  • 主机环境排查:当前主机未运行Nginx、Apache等常见端口占用服务,hosts文件保持系统默认配置未做修改,仅安装了搭载VirtualBox的Vagrant以及Laravel Homestead虚拟机
  • 对照模式验证:禁用调试配置后启动容器可正常运行,此时启动命令不再绑定用于Mono远程调试的55555端口,对应命令内容如下:
    docker run --rm     --mount type=bind,source=/Users/odelibalta/Documents/Code/GitHub/Lean/Launcher/config.json,target=/Lean/Launcher/config.json,readonly     -v /Users/odelibalta/Documents/Code/GitHub/Lean/Data:/Data:ro     -v /Users/odelibalta/Documents/Code/GitHub/Lean/Results:/Results     --name LeanEngine     -p 5678:5678     --expose 6000 -v /Users/odelibalta/Documents/Code/GitHub/Lean/Algorithm.Python:/Lean/Algorithm.Python quantconnect/lean:latest --data-folder /Data --results-destination-folder /Results --config /Lean/Launcher/config.json
    
    但该模式会丧失容器内的代码调试能力,无法满足Python策略开发的调试需求
  • 调试环境配置校验:已按照官方指引在VSCode中配置Mono版本为15.8,本地也安装了对应15.8版本的Mono,但执行msbuild --version时会返回参数识别错误,对应输出如下:
    Lean git:(master) ✗ msbuild --version
    Microsoft (R) Build Engine version 16.0.38-preview+g300887e680 for Mono
    Copyright (C) Microsoft Corporation. All rights reserved.
    
    MSBUILD : error MSB1001: Unknown switch.
    Switch: --version
    
    For switch syntax, type "MSBuild /help"
    

待解决目标

  • 排除端口误报占用问题,在保留容器内Python调试能力的前提下,正常启动Lean引擎容器
  • 修正msbuild命令的参数识别异常,匹配VSCode的Mono调试环境配置

内容的提问来源于stack exchange,提问作者ODelibalta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.11.08 20:15:04