简体   繁体   English

在 vscode 中如何设置默认容器

[英]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.

相关问题 VSCode 远程容器 — 如何打开 VSCode 的容器实例中的默认文件夹? - VSCode Remote Container — how to open the default folder in the container instance of VSCode? 如何让 PHP 调试器在 VsCode 中的 docker 容器内的断点处中断? - How do I get the PHP debugger to break on breakpoints inside a docker container in VsCode? 如何使用docker设置分配给容器的资源? - How do I set resources allocated to a container using docker? 如何在 Docker.DotNet 中设置容器的名称? - How do I set the Name of an Container in Docker.DotNet? 如何在我的 dockerfile 中为 Windows 容器设置系统路径? - How do I set System Path in my dockerfile for a Windows Container? 如何检查Docker容器中是否设置了环境变量? - How do I check whether an environment variable is set in a docker container? 如何在容器中的 HTTPS 上设置 NiFi - how do I set up NiFi on HTTPS in a container 如何为我的 docker 容器设置时区? - How do I set timezone for my docker container? VSCode 远程容器默认 python 解释器 - VSCode remote-container default python interpreter 在我的 Apache Docker 容器中,如何设置代理来路由其他代理未处理的所有内容? - In my Apache Docker container, how do I set up a Proxy to route everything not handled by other proxys?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM