You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何配置VSCode Remote使用非Git跟踪的自定义devcontainer.json?

配置VSCode使用自定义本地开发容器配置文件

步骤1:创建本地自定义配置文件

  • 在项目的.devcontainer目录下创建local_devcontainer.json文件
  • 推荐用extends字段继承团队配置(减少重复代码),仅添加个人自定义内容,示例:
{
  "extends": "./devcontainer.json",
  // 以下为个人自定义配置,会覆盖团队配置的同名项
  "features": {
    "ghcr.io/devcontainers/features/python:1": {
      "version": "3.11"
    }
  },
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-python.black-formatter"
      ]
    }
  }
}
  • 在项目.gitignore中添加.devcontainer/local_devcontainer.json,确保该文件不被Git跟踪

步骤2:让VSCode加载自定义配置

有两种常用方式:

方式一:通过命令面板手动选择

  • 打开命令面板(Windows/Linux:Ctrl+Shift+P;Mac:Cmd+Shift+P)
  • 输入并执行Remote-Containers: Open Folder in Container...,选择项目根目录
  • 在弹出的配置选择界面,选中local_devcontainer.json即可
  • 若已在容器环境中,执行Remote-Containers: Reopen in Container,再选择自定义配置文件

方式二:设置默认配置路径(永久生效)

  • 打开VSCode设置(Windows/Linux:Ctrl+,;Mac:Cmd+,),点击右上角「打开设置(JSON)」
  • 添加以下配置,指定默认使用的本地配置文件:
"remote.containers.defaultDevcontainerPath": "${workspaceFolder}/.devcontainer/local_devcontainer.json"
  • 后续打开该项目会自动加载本地配置;如需切回团队配置,修改该设置或通过命令面板重新选择

内容的提问来源于stack exchange,提问作者Lola

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.25 11:06:18