microsoft / vscode-docker

Docker Extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker
Other
1.19k stars 508 forks source link

Error response from daemon: No such container on python debug with docker #4187

Closed victorngeno-gro closed 5 months ago

victorngeno-gro commented 6 months ago

I have the following test project setup

project directory contents

With the following contents launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "debug-script",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "run-image",
            "python": {
                "projectType": "general",
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}",
                        "remoteRoot": "/app"
                    }
                ]
            }
        }
    ]
}

tasks.json

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "build-image",
            "type": "docker-build",
            "dockerBuild": {
                "dockerfile": "${workspaceFolder}/Dockerfile",
                "context": "${workspaceFolder}",
                "tag": "test-debug-image"
            },
            "platform": "python"
        },
        {
            "label": "run-image",
            "type": "docker-run",
            "dependsOn":["build-image"],
            "dockerRun": {
                "image": "test-debug-image",
                "containerName": "test-debug"
            },
            "python": {
                "file": "/app/run.py"
            }
        }
    ]
}

Dockerfile

FROM python:3.10

WORKDIR /app

COPY run.py ./run.py

ENTRYPOINT [ "python", "run.py" ]

run.py

def do_sum():
    x = 1
    y = 2
    return x+y

def main():
    result = do_sum()
    print(result)

if __name__ == "__main__":
    main()

Getting the following error Error response from daemon: No such container: test-debug

yet the container is running as below

~ - $ docker ps
CONTAINER ID   IMAGE                 COMMAND                  CREATED          STATUS                             PORTS                                         NAMES
d28b71b0083d   test-debug-image      "python3"                49 minutes ago   Up 49 minutes                                                                    test-debug

image

bwateratmsft commented 5 months ago

I'm not able to reproduce, the debugger attached normally and hit the breakpoint for me. It's possible Docker was being temperamental. Does the issue still reproduce?

AzCode-Bot commented 5 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!