这个周末我设置了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
Dockerfile:
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
如果我删除了git的Dockerfile安装并从容器中运行apt-get update && apt-get install git
,就没有问题。在这种情况下,git使用了我的主机ssh密钥(通过Windows上的ssh-agent服务加载),并且可以通过终端或vs代码本身来拉和推。
日志中没有错误或警告。
答案 0 :(得分:0)
好的,我过早发布了几分钟。
我检查了git配置,并且VS Code将我的Windows配置拉入了工作区,这是一个已知问题。
取消阻止的答案是将其更改为您的ssh位置(/usr/bin/ssh
):
core.sshcommand=C:/Windows/System32/OpenSSH/ssh.exe