Replies: 7 comments 4 replies
-
This is a great question. It would be enormously helpful to folks who use dev containers if git-credential-manger credentials could be passed into docker containers. I don't think there is going to be a simple bind-mount solution, because, as far as I can tell, GCM doesn't expose any sockets that can easily be forwarded. VSCode is actually able to do this. https://code.visualstudio.com/remote/advancedcontainers/sharing-git-credentials#_using-a-credential-helper That works perfectly, but as best I can tell they are using a custom solution that requires using their Dev Container extension in VSCode and containers set up by VSCode. So that won't work if you are using a custom dev container or have some other reason to want to forward GCM into Docker. I would be extremely interested in talking to anyone aware of, or interested in developing, a solution to this. It is only going to become more of an issue as organizations move towards requiring MFA for git access. |
Beta Was this translation helpful? Give feedback.
-
BTW, you can use GCM inside a docker container (at least for Azure DevOps) if you use the device flow login. For example in
This will prompt you to go to a link and enter your device code and then do login there (sort of like when you setup your tv to use a streaming account) But you will run into this issue of it storing the tokens in plaintext. Github issue. I'm not sure if that's a dealbreaker (might still be better than storing long-lived ssh keys), but wanted to put the info out there. |
Beta Was this translation helpful? Give feedback.
-
This is mostly a cross-post from an issue I raised with the vscode dev containers extension here, but its relevant (arguably more), to this discussion. TLDR: I think I could build a solution if I could understand why i can't get the same auth flow to trigger on my host machine when I run More detail here -- I think I understand the basics of how to build a solution, though there are still some things I can't quite work out which are blocking me putting together a POC. The basic idea would seem to be to install a simple git credential helper app on the container--call it On the host side, another service would be running--call it The flow would be something like this:
The The But I don't understand (a) how it can know which host and repo it should target, or (b) what the format of the In particular, if i do something like Somehow the VS Code Dev Containers extension has made this work, but I can't figure out how... |
Beta Was this translation helpful? Give feedback.
-
OK, I've written a utility that enables this use case, i.e., forwarding GCM-stored credentials (or really, any git credentials) into a docker container. More information and the code is here. I consider it POC for now. It works, but I haven't tested it extensively, and I want to think through the security implications a little more. But please free to check it out, report bugs, and suggest improvements. |
Beta Was this translation helpful? Give feedback.
-
@liiight if made a few tweaks, most notably adding webpack bundling which should make the scripts easier to install. אני מבין אם אתה לא יכול לראות עד אחרי פסח. 😉 חג שמח! |
Beta Was this translation helpful? Give feedback.
-
I just remembered I haven't tried this yet! I'll do it early next week! |
Beta Was this translation helpful? Give feedback.
-
No worries; we have been using it daily for the last two months and it has worked great. Has definitely solved the problem of being able to access GCM from inside a docker container for us. Feel free to raise any issues, thoughts, etc, on the github for that project. Thanks for taking a look! |
Beta Was this translation helpful? Give feedback.
-
Hi,
I was wondering if its possible to use GCM setup on a host machine when running a container.
I tried setting a mount to the GCM installation at
/usr/local/share/gcm-core/git-credential-manager
to the same location in the container but that didn't seem to work.Any ideas?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions