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

从VSCode迁移到WebStorm后Dev Container启动失败(exit code 17)

问题:WebStorm启动Dev Container失败,提示找不到.features.temp.dockerfile

操作流程

从VS Code迁移到WebStorm后,启动Dev Container的步骤:

  • 打开devcontainer.json文件,点击文件内的立方体图标
  • 选择“Create Dev Container and Mount Sources...”选项,再选择WebStorm

错误详情

执行后docker-compose进程以exit code 17终止,核心错误:

failed to read dockerfile: open .features.temp.dockerfile: no such file or directory

同时伴随警告:docker-compose文件中version属性已过时。尝试修改Dockerfile后问题仍未解决。

相关配置文件

devcontainer.json

// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose
{
    "name": "vtal api",
    "dockerComposeFile": [
        "../docker-compose.yaml",
        "docker-compose.yml"
    ],
    "service": "app",
    "workspaceFolder": "/home/node/app",
    "features": {
        "ghcr.io/devcontainers/features/common-utils:2": {},
        "ghcr.io/devcontainers-contrib/features/zsh-plugins:0": {
            "plugins": "git git-flow F-Sy-H zsh-autosuggestions zsh-completions",
            "omzPlugins": "https://github.com/z-shell/F-Sy-H https://github.com/zsh-users/zsh-autosuggestions https://github.com/zsh-users/zsh-completions"
        },
        "ghcr.io/stuartleeks/dev-container-features/shell-history:0": {}
    },
    "customizations": {
        "vscode": {
            "extensions": [
                "dbaeumer.vscode-eslint"
            ]
        }
    }
}

.devcontainer/docker-compose.yml

version: '3'
services:
  app:
    volumes:
      - .:/home/node/app:cached

根目录docker-compose.yaml

version: '3'

services:
  app:
    build: .
    container_name: my-api
    command: ./.docker/start.sh
    ports:
      - 8000:8000
    volumes:
      - .:/home/node/app

  postgres:
    container_name: my-postgres
    image: bitnami/postgresql
    ports:
      - 5432:5432
    environment:
      POSTGRES_USER: docker
      POSTGRES_PASSWORD: mysupersecret
      POSTGRES_DB: mydb
      PGDATA: /data/postgres
    volumes:
      - ./data/pg:/data/postgres

Dockerfile

FROM node:20.5.1-slim

USER node

WORKDIR /home/node/app

CMD ["tail", "-f", "/dev/null"]

解决方案

1. 修正Docker构建上下文配置

.features.temp.dockerfile是Dev Containers特性自动生成的临时文件,问题源于构建上下文不匹配:根目录docker-compose.yaml中app服务的build: .使用根目录作为上下文,但临时文件生成在.devcontainer目录下,导致找不到。

修改根目录docker-compose.yaml的build配置:

app:
  # 替换原有的build: .
  build:
    context: .
    dockerfile: Dockerfile

2. 调整Docker Compose文件加载顺序

当前dockerComposeFile先加载根目录文件,会覆盖.devcontainer内的特性注入配置。调整顺序优先加载.devcontainer下的配置:

"dockerComposeFile": [
    "docker-compose.yml",
    "../docker-compose.yaml"
]

3. 升级docker-compose版本(消除警告)

将所有docker-compose文件中的version: '3'改为version: '3.8',消除版本过时警告。

4. 清理缓存后重启

执行命令清理Docker缓存,避免旧配置干扰:

docker-compose down -v
docker system prune -af

完成以上操作后,重新在WebStorm中启动Dev Container即可。

内容的提问来源于stack exchange,提问作者Felipe Gouvêa

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.16 07:57:23