Docker、WSL2 和 vscode - 错误的 git/ssh 路径

Docker, WSL2 & vs code - bad git/ssh path

我在这个周末设置了我的 WSL2、Docker 和 vs 代码环境。

我在尝试使用 git:

时发现问题
root@bb7f765df0d6:/var/www/html# git clone git@github.com:hsimah/my-repo.git
Cloning into 'my-repo'...
fatal: cannot run C:/Windows/System32/OpenSSH/ssh.exe: No such file or directory
fatal: unable to fork

Docker文件:

FROM wordpress:latest
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
    && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
    && apt-get -y install git \
    && apt-get autoremove -y \
    && apt-get clean -y \
    && rm -rf /var/lib/apt/lists/*
ENV DEBIAN_FRONTEND=dialog

如果我从我的容器中删除 Docker 和 git 和 运行 apt-get update && apt-get install git 的文件安装,则没有问题。在这种情况下 git 使用我的主机 ssh 密钥(通过 Windows 上的 ssh-agent 服务加载)并且可以通过终端或 vs 代码本身拉和推。

日志中没有错误或警告。

好吧,我发布得太快了几分钟。

我检查了 git 配置,VS Code 正在将我的 Windows 配置拉入工作区,这是一个已知问题。

解锁答案是将其更改为您的 ssh 位置 (/usr/bin/ssh): core.sshcommand=C:/Windows/System32/OpenSSH/ssh.exe