我的目标是为我的VS Code Debugger设置配置 .
我的遗留代码是使用docker容器来运行redis,并使用gulp任务运行器来启动应用程序 . 我的工作流程包含我在终端中键入的以下命令:

docker-compose up 用db运行redis

gulp default 启动应用程序的服务器

到目前为止,我已成功为gulp任务创建了配置,但仍在努力为调试器中的docker设置配置 .

Docker Desktop在Windows 10 Pro上本地安装

Docker version: 2.0.0.0-win81 (29211)

docker文件:docker-compose.yml

version: "2"
services:
  redis:
    container_name: redis
    image: redis:latest
    ports:
      - 7113:6379
mariadb-test:
    container_name: mariadb-test
    image: wodby/mariadb
    ports:
      - 6604:3306
    environment:
      - MYSQL_ROOT_PASSWORD=***
      - MYSQL_USER=****_****
      - MYSQL_PASSWORD=****
      - MYSQL_DATABASE=****
      - MYSQL_CHARACTER_SET_FILESYSTEM=utf8mb4
      - MYSQL_CHARACTER_SET_SERVER=utf8mb4
      - MYSQL_CLIENT_DEFAULT_CHARACTER_SET=utf8mb4
      - MYSQL_COLLATION_SERVER=utf8mb4_unicode_ci
      - MYSQL_INIT_CONNECT=SET NAMES utf8mb4

我的launch.json配置

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Gulp",
      "program": "${workspaceFolder}/node_modules/gulp/bin/gulp.js",
      "args": [
        "default"
      ]
    },
    {
      "type": "node",
      "request": "attach",
      "name": "Docker",
      "address": "localhost",
      "port": 6379,
      "localRoot": "${workspaceFolder}",
      "remoteRoot": "/",
    }
  ]
}

我一直收到这个错误:

Error: Cannot connect to runtime process, timeout after 10000 ms - (reason: Cannot connect to the target: connect ECONNREFUSED 127.0.0.1:6379).