'Running Docker in WSL2, facing git login problem

I'm trying to run docker in WSL2. I installed Ubuntu and it starts fine, I configured my git access with ssh key stored in .ssh and tested the access with ssh my-git-server.com and it gives the welcome information. I also installed docker desktop for windows and selected WSL integration.

I did docker login to the git server for the docker, it was also successful.

I can start docker-compose and get the docker running.

When I tried to run cmake in docker, I was hit with login request:

Username for 'https://"my-git-server".com':

and I can use my username and password to login, but then it will pop up request for that again.

I tried to add docker credential helper with no help for this issue. git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager.exe" doesn't help this issue either, because docker image doesn't have the c drive mounted, doesn't have git binaries or docker binaries either.



Solution 1:[1]

Some action in your cmake build tries to access your repo through https, not ssh.

You may either :

  1. spot that action and change the way your repository gets cloned,

  2. or add a insteadOf configuration entry within your docker environment :

git config --global \
        url."[email protected]:".insteadOf my-git-server.com/

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1