Closed djswagerman closed 8 months ago
This scenario should be working. There might be a bug in the VSCode task / launch system that's preventing the task from correctly being picked up.
Thanks for confirming. Is there any workaround I can try or am I stuck with manually switching the tasks in the tasks.json until the bug is resolved?
I just checked and I'm able to reproduce. I think this is a bug in VSCode. I'll try to find an existing one or otherwise open one.
Yeah, I think this is https://github.com/microsoft/vscode/issues/164485. The two docker-run
tasks are nearly identical, differing only in dependsOn
, and the task system can't distinguish between them.
@djswagerman I found a potential workaround that is very easy. You just need to add "dockerRun": {}
to one of the docker-run
tasks, like this:
{
"version": "2.0.0",
"tasks": [
{
"type": "docker-build",
"label": "docker-build",
"dockerBuild": {
"context": "${workspaceFolder}",
"dockerfile": "${workspaceFolder}/prod.Dockerfile",
"tag": "designguide_prod"
},
"problemMatcher": []
},
{
"type": "docker-run",
"label": "docker-run-test: debug",
"dependsOn": [
"docker-build-test"
],
"python": {
"args": [
"runserver",
"0.0.0.0:8000",
"--nothreading",
"--noreload"
],
"file": "manage.py"
},
"dockerRun": {} // Add this line to one of the `docker-run` tasks
},
{
"type": "docker-run",
"label": "docker-run: debug",
"dependsOn": [
"docker-build"
],
"python": {
"args": [
"runserver",
"0.0.0.0:8000",
"--nothreading",
"--noreload"
],
"file": "manage.py"
}
},
{
"type": "docker-build",
"label": "docker-build-test",
"dockerBuild": {
"context": "${workspaceFolder}",
"dockerfile": "${workspaceFolder}/test.Dockerfile",
"tag": "designguide_test"
},
"problemMatcher": []
}
]
}
Thanks! Your workaround worked for me! (for people landing here, if you add "dockerRun": {} to both tasks, I doesn't work. I added it to first "docker-run" task in my tasks.json)
Awesome, glad it worked! I'll close this issue since there's nothing more we can do with it but hopefully anyone running into it will find this.
I am creating a django / python app and want to be able to start debugging in a container. I would like to have two docker files, one for a test and one for a production environment. The problem is I can only have one supported debug configuration, depending on which 'docker-run' tasks comes first in the tasks.json file. Whatever comes last in the file, works, whatever comes first, gives the error message: "Could not find the task 'docker-run-test: debug'" when starting the debug configuration.
This seems to be a bug. If this isn't a bug, I'd like to understand how I can have multiple docker based debug configurations, configured, or what I may miss in my configuration.
Configuration info:
I created a 'prod.Dockerfile':
and a test.Dockerfile:
tasks.json:
launch.json