VSCode multiple docker run task recognize only the last docker run task
Asked Answered
E

1

6

I have 2 tasks in visual studio code to run 2 different images into containers. Only the last docker run task is recognized by vscode.

This is my tasks.json file

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "docker-build-1",
      "type": "docker-build",
      "platform": "python",
      "dockerBuild": {
        "tag": "image1:latest",
        "dockerfile": "${workspaceFolder}/app1/dev.Dockerfile",
        "context": "${workspaceFolder}/",
        "pull": true
      }
    },
    {
      "label": "docker-build-2",
      "type": "docker-build",
      "platform": "python",
      "dockerBuild": {
        "tag": "image2:latest",
        "dockerfile": "${workspaceFolder}/app2/dev.Dockerfile",
        "context": "${workspaceFolder}/",
        "pull": true
      }
    },
    
    
    {
      "label": "docker-run-1",
      "type": "docker-run",
      "dependsOn": [
        "docker-build-1"
      ],
      "python": {
        "module": "app.main"
      },
      "dockerRun": {
        "network": "mynetwork"
      }
    },
    {
      "label": "docker-run-2",
      "type": "docker-run",
      "dependsOn": [
        "docker-build-2"
      ],
      "python": {
        "module": "app.main"
      },
      "dockerRun": {
        "network": "mynetwork"
      }
    },
    
  ]
}

When vscode shows the menu for running task, only thask docker-run-2 is showing:

enter image description here

Actually, only the last docker run task in the tasks.json file is shown. If I change the order in the list of tasks, then vscode only recognize docker-run-1. I searched in the documentation and it doesn't says anything about this behaviour. Any idea why this is happening? The idea is to setup 2 debug configurations in vscode for the 2 apps, but running the debug config for the app that is not the last produce an error in vscode:

enter image description here

Expectancy answered 25/12, 2021 at 15:56 Comment(0)
I
0

Came across this same issue today. Seems that the "dockerRun" attribute between the run tasks has to be different. In my case i just added a test environment variable to one of the tasks and then both started to appear in the task list.

Impletion answered 13/9, 2022 at 13:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.