5

I want to use my Windows 10 host machine's git credentials with docker-compose without having to enter the credentials within the container.

Edit

Saving my key in the image should not be done. Developers will all be running containers based on the same image. Ideally when the container starts up, through docker-compose, it will pull from the git repo, using the individual developer's git credentials.

The image is Ubuntu, while the host is Windows 10 using Git Credential Manager for Windows (GCM) as a credential helper.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Blanthor
  • 2,568
  • 8
  • 48
  • 66
  • Possible duplicate of [Clone private git repo with dockerfile](https://stackoverflow.com/questions/23391839/clone-private-git-repo-with-dockerfile) – eol Jul 23 '18 at 14:12
  • @eol I have considered this post. However I do not want my private key copied into a docker image. I want all developers to be able to use their credentials as they run containers built on the same image. – Blanthor Jul 23 '18 at 14:44
  • 1
    @eol I have edited my post. This is not a duplicate, because I do not want the credentials saved in the image. – Blanthor Jul 23 '18 at 14:54

1 Answers1

0

You can use a volume binding to mirror your key at runtime into the container. If all the developers use the same directory for their private key it works with everybody.

A minimal docker-compose.yml would look like this.

version: "3.2"
services:
  custom-service:
    image: whatever
    volumes:
      - "/path/to/private/key/on/local/machine/ssh:/path/to/ssh/in/docker/container"
WeGi
  • 1,908
  • 1
  • 21
  • 33
  • I have seen examples where this is done when the host uses a flavor of Linux. The trouble is I'm having a hard time finding such a path in Windows 10. – Blanthor Jul 23 '18 at 15:46