VS code Docker 扩展无法“附加 shell”

Pau*_*der 3 docker visual-studio-code

当我尝试右键单击 -> 在任何 docker 盒子上附加 shell 时,终端窗口将打开并输出以下内容:

 *  Executing task: docker exec -it <container_id> bash 

zsh:1: command not found: docker

 *  The terminal process "/bin/zsh '-c', 'docker exec -it <container_id> bash'" failed to launch (exit code: 127). 
 *  Terminal will be reused by tasks, press any key to close it. 
Run Code Online (Sandbox Code Playgroud)

当我跑步时docker exec -it <container_id> bash手动运行时,它有效。“附加外壳”下拉选项不起作用。为什么?

我尝试将默认终端更改为 bash,但没有成功。我使用的是配备 M1 芯片的 Mac Monterey 12.1。经过一番挖掘,我发现一个线程提到这可能是 Mac 的问题,但该线程使用的是不同的操作系统版本。

Pau*_*der 6

该问题与以下不同问题的答案有关:/sf/answers/4571289971/

“vscode 中的 npm 脚本是用 /bin/zsh -c (非登录非交互式)启动的,这意味着 ~/.zshrc 中的脚本不会被执行(并且出于同样的原因 ~/.zprofile)。但是,即使在非登录非交互模式,加载~/.zshenv。”

就我而言,这是我的路径变量。

为了修复我遵循

Open ~/.zshrc and move whatever scripts that is loading yarn into ~/.zshenv
Run Code Online (Sandbox Code Playgroud)

将包含的路径变量复制docker到 ~/.zshenv 中。

~/.zshenv

export PATH="/usr/local/bin:$PATH"
Run Code Online (Sandbox Code Playgroud)