[英]in vscode how do I set the default container
Looking at the vscode documentation https://code.visualstudio.com/docs/remote/containers and section查看 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).
I can see that the correct container is launched each time, but I do not see a reference to it in the .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"
}
then in section https://code.visualstudio.com/docs/remote/containers#_create-a-devcontainerjson-file然后在https://code.visualstudio.com/docs/remote/containers#_create-a-devcontainerjson-file部分
"image": "mcr.microsoft.com/vscode/devcontainers/typescript-node:0-12",
If I am using docker desktop on windows how do format the uri to match the docker desktop container location?如果我在 windows 上使用 docker 桌面,如何格式化 uri 以匹配 docker 桌面容器位置? for example a
docker ps -a
returns a NAME of interesting_mccarth
.例如,一个
docker ps -a
返回一个interesting_mccarth
的名称。 I do not see how the above string matches to my container I wish to use as default.我看不到上面的字符串如何与我希望用作默认值的容器匹配。
In your example, the devcontainer.json
file references the Dockerfile
and it is the Dockerfile
that references the image to use.在您的示例中,
devcontainer.json
文件引用了Dockerfile
并且它是引用要使用的图像的Dockerfile
。
"build": {
"dockerfile": "Dockerfile"
}
So whether it is a local or remote image that you want to reference inside your Dockerfile
is really up to you.因此,您想在
Dockerfile
中引用本地图像还是远程图像完全取决于您。 Here is an SO answer describing how to use a local image inside a Dockerfile
.这是一个 SO 答案,描述了如何在
Dockerfile
中使用本地图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.