I've googled and experimented with this a lot over the last few weeks and can't seem to hit the right combo to get this working.
I'm on Windows 10, and am using VSCode with Docker and WSL2. For the life of me I can't get git + ssh keys working so that I can push and pull from within my Docker containers.
Using the Windows Terminal app and Ubuntu 20.04 on WSL2 works fine. I copied my SSH keys over from the Windows side of things and changed the permissions appropriately and have no issues there.
In my project using Docker Compose, I've tried using a volume (~/.ssh:/root/.ssh), but the issue with this configuration is the owner of everything in the .ssh directory becomes 1000:1000 and when I try to do any git operations, I get a message:
bad permissions or owner on /root/.ssh/config
I've also tried not having that volume and using the ssh agent forwarding as outlined in the VSCode documentation, but when I try that I get permission denied from github when I try to pull or push.
Does anyone have any luck getting this working? It isn't a huge deal to do all my git commands from a terminal, but it'd sure be convenient to be able to do it successfully from within the Docker container.