Search code examples
dockerfilevscode-remotewindows-subsystem-for-linux

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


I set up my WSL2, Docker and vs code environment this weekend.

I am finding an issue when attempting to use git:

root@bb7f765df0d6:/var/www/html# git clone [email protected]: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

If I remove the Dockerfile install of git and run apt-get update && apt-get install git from my container there is no issue. In this case git uses my host ssh keys (loaded via ssh-agent service on Windows) and can pull and push both via terminal or vs code itself.

There are no errors or warnings in the log.


Solution

  • Okay I posted a few minutes too soon.

    I checked the git config and VS Code was pulling my Windows config into the workspace, it's a known issue.

    Unblocking answer is to change this to your ssh location (/usr/bin/ssh): core.sshcommand=C:/Windows/System32/OpenSSH/ssh.exe