尝试在 Visual Studio Code 的 Docker 容器中调试 Python 代码时遇到错误

Error encountered trying to debug Python code within a Docker container in Visual Studio Code

提问人:Paul 提问时间:11/15/2023 更新时间:11/15/2023 访问量:12

问:

我正在尝试调试在Visual Studio Code的Docker容器中运行的Python程序。按照 https://code.visualstudio.com/docs/containers/debug-python 上的说明,我配置了 .vscode/tasks.json 文件,如下所示:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "docker-build",
            "label": "docker-build",
            "platform": "python",
            "dockerBuild": {
                "tag": "gdl3d_data_generator:latest",
                "dockerfile": "${workspaceFolder}/env/Dockerfile.data_generator",
                "context": "${workspaceFolder}",
                "pull": true
            }
        },
        {
            "type": "docker-run",
            "label": "docker-run: debug",
            "dependsOn": [
                "docker-build"
            ],
            "dockerRun": {
              "volumes": [
                {
                  "containerPath": "/rawdata", "localPath": "/Users/ac8dqzz/Documents/Development/DSC/OCSD/TrainingData/rawdata"
                }
              ]
            },
            "python": {
                "file": "src/app/transformation/setup_design/data_generator.py",
                "args": [
                    "rawdata_dirpath",
                    "/rawdata"
                ],
                
            }
        }
    ]
}

我配置了 .vscode/launch.json 文件,如下所示:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true
        },
        {
            "name": "Docker: Python - General",
            "type": "docker",
            "request": "launch",
            "preLaunchTask": "docker-run: debug",
            "python": {
                "pathMappings": [
                    {
                        "localRoot": "${workspaceFolder}",
                        "remoteRoot": "/workspace",
                    }
                ],
                "projectType": "general"
            }
        }
    ]
}

当我尝试在 Visual Studio Code 中启动“Docker: Python - General”调试器配置时,出现以下错误:

> docker image build --pull --file '/Users/ac8dqzz/Documents/Development/DSC/OCSD/GDL3D/env/Dockerfile.data_generator' --tag 'gdl3d_data_generator:latest' --label 'com.microsoft.created-by=visual-studio-code' '/Users/ac8dqzz/Documents/Development/DSC/OCSD/GDL3D' <

#0 building with "desktop-linux" instance using docker driver

#1 [internal] load build definition from Dockerfile.data_generator
#1 transferring dockerfile: 494B done
#1 DONE 0.0s

#2 [internal] load .dockerignore
#2 transferring context: 426B done
#2 DONE 0.0s

#3 [internal] load metadata for docker.io/library/gdl3d:latest
#3 ERROR: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
------
 > [internal] load metadata for docker.io/library/gdl3d:latest:
------
Dockerfile.data_generator:3
--------------------
   1 |     # Build a docker image to run the src.app.transformation.setup_design.data_generator component
   2 |     # FROM 695875302211.dkr.ecr.us-east-1.amazonaws.com/gdl3d:latest
   3 | >>> FROM gdl3d:latest
   4 |     
   5 |     # Update the src directory in the image
--------------------
ERROR: failed to solve: gdl3d:latest: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
Process exited with code 1

为什么会出现此错误,我该怎么做才能解决?

docker visual-studio-code 调试 vscode-debugger

评论


答: 暂无答案