linux - 如何将凭证烘焙到 git 的 docker 镜像中?

标签 linux git authentication docker alpine-linux

这实际上是我之前的一个问题 one .

我正在尝试使用 docker 托管个人笔记网络服务,并希望备份该服务生成的数据(我的笔记)。 目前,我计划使用 git 提交、 pull 和推送到一个存储库以达到我的目的。

要执行 git pull 和 push,我的 docker 镜像需要托管我的凭据。实现这一目标的最简单而安全的方法是什么?

到目前为止我做了什么:

  • 我选择 Alpine 作为我的服务图像的基础图像。
  • 因为我只需要 git 的凭据,所以我认为将 git 凭据助手放入图像中可能会解决我的问题。我可以在构建期间将凭据保存到助手,并在运行时使用它们。
  • 根据 this article,我在谷歌上搜索了一会儿,决定使用 libsecret 作为我的 git 凭证助手。 .
  • 我已经安装了 libsecret 并将我的 git 凭据助手设置为 git-credential-libsecret

但是,到目前为止,我无法使 git-credential-libsecret 发挥作用。以下是我遇到的几个问题:

  • 首先,我测试了git-credential-libsecret get,得到如下错误:

    CRITICAL **: could not connect to Secret Service: Cannot spawn a message bus without a machine-id: Unable to load /var/lib/dbus/machine-id or /etc/machine-id: Failed to open file */var/lib/dbus/machine-id*: No such file or directory

    • 我(可能?)通过安装 dbus 并运行 dbus-uuidgen >/var/lib/dbus/machine-id 解决了这个问题
  • 然后我尝试再次运行 git-credential-libsecret get。这一次,它报告说:

    CRITICAL **: could not connect to Secret Service: Cannot autolaunch D-Bus without X11 $DISPLAY

    • 我尝试安装 dbus-x11 并运行 dbus-launch --sh-syntax( from here ) 但这次没有成功。错误继续。

最后,我想知道:

  1. 我的方向是否正确(使用 git credential helper)来实现我的目标?
  2. 如果是这样,我该如何解决 X11 问题?
  3. 是否有任何其他快速和干净的方法来备份带有版本控制的 docker 中的数据?

最佳答案

如果您的 git 提供商支持使用公钥的 ssh,我认为最简单的方法是切换到它们。您也不必复制密码。

你需要:

关于linux - 如何将凭证烘焙到 git 的 docker 镜像中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48237435/

相关文章:

linux - 如何让linux patch util在补丁文件中使用env var

linux - 在 ldap_access_filter 中指定 AND 和 OR 条件

java.lang.ArrayIndexOutOfBoundsException : -1

git - 阻止新分支获取 Git 中的旧提交历史记录

windows - GIT 预提交 Hook ,它在修改/添加的文件中搜索非 UTF-8 编码(如果找到任何文件,则拒绝提交)

reactjs - 如何以高性能方式连接两个 React 应用程序

Javascript/Rails 授权获取 header

python - Selenium 无法启动 Chromedriver - Ubuntu 16.04,Python 3.6.3

git - Git初学者:分离Git提交

c# - 使用单个网站进行身份验证的多个 MVC5 网站 (ASP.NET Identity v2)