
run和run interactive
3. 使用VScode进入Vscode内部
使用Run interactive 之后在容器部分可以看到容器建立了
这个时候对着建立的容器右键选择Attach Visual Studio Code这样就是进入容器内调试Vscode了

点击Attach Visual Studio Code进入容器可以看到,需要先向容器安装一些Vscode的插件,确保能连接容器。

下面可以看到连接成功了到容器内部了,左下角可以看到是容器

打开文件夹选择容器目录

创建了测试的python文件,如果发现没有办法调试的话

在插件部分,安装容器内的python插件,点击下图中的下载按钮就可以了

从下面可以看到是容器内的python环境


!!!一般不能调试运行的情况是使用服务器的python环境是调试失败的。
参考链接
Please change your code to your devcontainer.json
修改devcontainer.json
{
"name": "Anaconda (Python 3)",
"build": {
"context": "..",
"dockerfile": "Dockerfile",
"args": {
"NODE_VERSION": "none"
}
},
"settings": {
"python.defaultInterpreterPath": "/opt/conda/bin/python",
"python.linting.enabled": true,
"python.linting.pylintEnabled": true,
"python.formatting.autopep8Path": "/opt/conda/bin/autopep8",
"python.formatting.yapfPath": "/opt/conda/bin/yapf",
"python.linting.flake8Path": "/opt/conda/bin/flake8",
"python.linting.pycodestylePath": "/opt/conda/bin/pycodestyle",
"python.linting.pydocstylePath": "/opt/conda/bin/pydocstyle",
"python.linting.pylintPath": "/opt/conda/bin/pylint"
},
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance"
],
"runArgs": ["--gpus","all"
],
"remoteUser": "vscode",
}