Git Credentials Inside Docker Dev Container  | Helpfulz

Git Credentials Inside Docker Dev Container 

November 01, 2022

I started building docker dev containers because i love the idea behind them and wanted to start using them everywhere.  Seems to be the way docker influences developers, it can be pretty exciting and suddenly you want to change every project you ever built. 

One major concern i was having that was slowing down my integration was being able to properly configure git credentials.

I use an ssh key on my machine to clone git repositories and manage them. That’s how i learned and i find it easy. 

However i was running into an issue when i would start up my dev container, after i made some adjustments and tried to push the changes, i would get an error code that read 

SSH Access – Permission denied (publickey)

computer

I found a solution that helped me get past this. First in my terminal:

ssh-add -K ~/.ssh/[your-private-key]

Then i modified this file ~/.ssh/config

I added:

Host *
  UseKeychain yes
  AddKeysToAgent yes
  IdentityFile ~/.ssh/[your-private-key]

After making this update, you’ll likely need to reopen the visual studio code window.

Now my dev containers are a lot more convenient because i can get them just how i like them, and i don’t have to leave that environment to make a git commit.


Profile picture

Written by IzzleNizzle who can be found playing around in the mountains of Utah. ⛰️ You should follow Iz on Twitter

© 2022, Built with Gatsby and WordPress