You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Visual Studio 2022 Docker Compose调试异常问题求助

问题描述
  • 使用Visual Studio 2022通过Docker Compose调试前后端项目,首次启动调试正常
  • 停止调试后再次启动,前端容器状态显示unhealthy,后端容器运行正常,同时出现无法连接80端口的错误
  • 停止调试时长期卡在“停止调试中”,必须通过任务管理器结束VS进程才能重新调试
  • 仅本地PC出现该问题,团队其他成员无此情况
  • 已尝试操作:管理员身份运行VS、修改端口、清理Docker容器,均无效
Docker Compose配置
services:
  xxxxxxx.backend.httpaggregator:
    image: ${CI_REGISTRY}/${CI_REPOSITORY}/webapi.backend.httpaggregator:${CI_TAG}
    build:
      context: .
      dockerfile: ApiGateways/WebApi.Backend.HttpAggregator/Dockerfile
    volumes:
      - trueerp_files:/app/files
    healthcheck:
      test: ["CMD-SHELL", "curl --fail http://xxxxxxxx-webapi.backend.httpaggregator/HealthCheck/Ping || exit 1"]
      interval: 10s
      timeout: 10s
      retries: 5
      start_period: 10s
    networks:
      - xxxxxxx_network
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
    ports:
      - "8082:80"

  xxxxxxx-frontend:
    image: ${CI_REGISTRY}/${CI_REPOSITORY}/frontend:${CI_TAG}
    build:
      context: .
      dockerfile: WebApps/frontend/Dockerfile
    healthcheck:
      test: ["CMD-SHELL", "curl --fail http://trueerp-erpmvc/HealthCheck/Ping || exit 1"]
      interval: 5s
      timeout: 5s
      retries: 3
      start_period: 30s
    networks:
      - xxxxxxx_network
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=http://+:80
    ports:
      - "8083:80"
      
networks:
  xxxxxx_network:
    external: true

volumes:
  xxxxx_files:
排查与解决建议

1. 修正前端健康检查配置

前端健康检查的http://trueerp-erpmvc/HealthCheck/Ping可能存在解析或访问问题:

  • 进入前端容器执行ping trueerp-erpmvc,确认主机名是否能正常解析
  • 将健康检查命令替换为容器内部本地地址:["CMD-SHELL", "curl --fail http://localhost/HealthCheck/Ping || exit 1"],避免依赖外部网络解析

2. 彻底清理Docker残留资源

常规清理可能不彻底,执行以下命令:

  • docker-compose down -v --rmi all:删除所有相关容器、卷和镜像
  • docker network prune:清理未使用的网络
  • 重启Docker Desktop后重新构建调试

3. 清理VS调试残留进程

停止调试时进程无法正常退出,手动清理:

  • 打开任务管理器,结束所有dotnet、docker-compose.exe、docker-desktop.exe相关进程
  • 关闭VS的快速启动功能:进入VS设置 → 项目和解决方案 → 生成并运行,取消勾选"启用快速启动"

4. 调整Docker Compose依赖与端口

  • 给前端容器添加后端依赖,确保后端启动后再启动前端:
    xxxxxxx-frontend:
      # 其他配置保持不变
      depends_on:
        - xxxxxxx.backend.httpaggregator
    
  • 修改前端容器的端口配置,避免潜在冲突:
    xxxxxxx-frontend:
      environment:
        - ASPNETCORE_URLS=http://+:8080
      ports:
        - "8083:8080"
    

5. 重置VS调试配置

  • 删除VS组件缓存:进入%APPDATA%\Microsoft\VisualStudio\<你的VS版本号>,删除ComponentModelCache文件夹
  • 重置VS设置:打开VS → 工具 → 导入和导出设置 → 重置所有设置

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.13 01:27:20