【问题标题】:Can I use my Windows 10 host's git credentials in docker-compose?我可以在 docker-compose 中使用我的 Windows 10 主机的 git 凭据吗?
【发布时间】:2018-07-23 13:25:41
【问题描述】:

我想将我的 Windows 10 主机的 git 凭据与 docker-compose 一起使用,而无需在容器中输入凭据。

编辑

不应将我的密钥保存在图像中。开发人员都将基于相同的镜像运行容器。理想情况下,当容器启动时,通过 docker-compose,它将使用单个开发人员的 git 凭据从 git repo 中提取。

映像是 Ubuntu,而主机是 Windows 10,使用 Git Credential Manager for Windows (GCM) 作为凭证​​助手。

【问题讨论】:

  • @eol 我已经考虑过这篇文章。但是我不希望将我的私钥复制到 docker 映像中。我希望所有开发人员在运行基于同一映像构建的容器时都能够使用他们的凭据。
  • @eol 我已经编辑了我的帖子。这不是重复的,因为我不希望将凭据保存在图像中。

标签: git docker docker-compose


【解决方案1】:

您可以使用卷绑定在运行时将您的密钥镜像到容器中。如果所有开发人员都使用相同的目录作为他们的私钥,那么它适用于每个人。

一个最小的 docker-compose.yml 看起来像这样。

version: "3.2"
services:
  custom-service:
    image: whatever
    volumes:
      - "/path/to/private/key/on/local/machine/ssh:/path/to/ssh/in/docker/container"

【讨论】:

  • 我见过一些例子,当主机使用 Linux 时会这样做。问题是我很难在 Windows 10 中找到这样的路径。
猜你喜欢
  • 2015-05-04
  • 2011-10-22
  • 2016-08-19
  • 1970-01-01
  • 2012-01-22
  • 1970-01-01
  • 2019-11-22
  • 2011-01-16
  • 1970-01-01
相关资源
最近更新 更多