在 vscode 如何设置默认容器
in vscode how do I set the default container
查看 vscode 文档 https://code.visualstudio.com/docs/remote/containers 和部分
3. After picking the starting point for your container, VS Code will add the dev container configuration files to your project (.devcontainer/devcontainer.json).
我可以看到每次都启动了正确的容器,但我没有在 .devcontainer/devcontainer.json
中看到对它的引用
{
"name": "myContainer",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bungcip.better-toml"
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
然后在 https://code.visualstudio.com/docs/remote/containers#_create-a-devcontainerjson-file
部分
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12",
如果我在 windows 上使用 docker 桌面,如何格式化 uri 以匹配 docker 桌面容器位置?例如 docker ps -a
returns interesting_mccarth
的名称。我看不出上面的字符串如何匹配我希望用作默认值的容器。
在您的示例中,devcontainer.json
文件引用了 Dockerfile
,Dockerfile
引用了要使用的图像。
"build": {
"dockerfile": "Dockerfile"
}
因此,您想要在 Dockerfile
中引用的是本地图像还是远程图像完全取决于您。 Here is an SO answer 描述如何在 Dockerfile
.
中使用本地图像
查看 vscode 文档 https://code.visualstudio.com/docs/remote/containers 和部分
3. After picking the starting point for your container, VS Code will add the dev container configuration files to your project (.devcontainer/devcontainer.json).
我可以看到每次都启动了正确的容器,但我没有在 .devcontainer/devcontainer.json
{
"name": "myContainer",
"build": {
"dockerfile": "Dockerfile"
},
"runArgs": [
"--cap-add=SYS_PTRACE",
"--security-opt",
"seccomp=unconfined"
],
// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash",
"lldb.executable": "/usr/bin/lldb",
// VS Code don't watch files under ./target
"files.watcherExclude": {
"**/target/**": true
}
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bungcip.better-toml"
],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "rustc --version",
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
然后在 https://code.visualstudio.com/docs/remote/containers#_create-a-devcontainerjson-file
部分"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12",
如果我在 windows 上使用 docker 桌面,如何格式化 uri 以匹配 docker 桌面容器位置?例如 docker ps -a
returns interesting_mccarth
的名称。我看不出上面的字符串如何匹配我希望用作默认值的容器。
在您的示例中,devcontainer.json
文件引用了 Dockerfile
,Dockerfile
引用了要使用的图像。
"build": {
"dockerfile": "Dockerfile"
}
因此,您想要在 Dockerfile
中引用的是本地图像还是远程图像完全取决于您。 Here is an SO answer 描述如何在 Dockerfile
.