WSL环境下VS Code无法使用Dev Containers的问题求助
问题:WSL2环境下VS Code Dev Container启动失败
极简复现示例
目录结构:
$ tree -a . ├── .devcontainer │ └── devcontainer.json └── README.md
.devcontainer/devcontainer.json 配置内容:
{ "name": "Test", "image": "alpine:latest" }
启动错误日志
打开文件夹并选择「在容器中重新打开」时,出现如下错误:
Stop (208 ms): Run: docker start 8d4a1484f7746e918f18f886da95d0803729ec19cd671bdd76b15307f2658a77 Error: Command failed: docker start 8d4a1484f7746e918f18f886da95d0803729ec19cd671bdd76b15307f2658a77 at HR (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:239:2183) at tb (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:239:2121) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async QR (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:245:2006) at async cb (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:245:3110) at async i_ (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:245:13194) at async n_ (/home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js:245:12950) Stop (464 ms): Run in Host: /home/user/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/user/test-containers --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\test-containers --log-level debug --log-format json --config /home/user/test-containers/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true Exit code 1 Command failed: /home/user/.vscode-server/bin/da76f93349a72022ca4670c1b84860304616aaa2/node /home/user/.vscode-remote-containers/dist/dev-containers-cli-0.241.3/dist/spec-node/devContainersSpecCLI.js up --workspace-folder /home/user/test-containers --workspace-mount-consistency cached --id-label devcontainer.local_folder=\\wsl.localhost\Ubuntu-20.04\home\user\test-containers --log-level debug --log-format json --config /home/user/test-containers/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root true Exit code 1 Start: Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\user\test-containers Stop (57 ms): Run: wsl -d Ubuntu-20.04 -e wslpath -u \\wsl.localhost\Ubuntu-20.04\home\user\test-containers
终端验证Docker正常运行
直接在WSL2终端中运行Docker命令正常:
$ docker run -it alpine:latest echo "hello" hello
补充信息
- 相同示例在Windows原生环境下可正常启动
- 推测问题出在WSL2与VS Code Dev Container的交互逻辑上
内容的提问来源于stack exchange,提问作者nowox
相关产品推荐
相关产品推荐

