【问题标题】:Building a Docker image from a private GitHub repository with docker-compose使用 docker-compose 从私有 GitHub 存储库构建 Docker 映像
【发布时间】:2021-03-26 11:59:39
【问题描述】:

我知道可以提供一个 GitHub HTTP URL 作为服务的构建上下文:

version: '3.9'

services:
  my-app:
    build: https://github.com/rambo/my-app.git

以上内容适用于公共回购。但是,如果 Dockerfile 存储在需要身份验证的私有存储库中(例如通过 SSH)怎么办。是否支持以下示例?

services:
  my-app:
    build: ssh://git@github.com:rambo/my-app.git

我尝试了上述配置的多种变体,但似乎没有任何效果。

【问题讨论】:

  • 我认为存储库应该包含所有必需的源。或者你应该基于代码构建一个镜像,推送到 Docker Registry,然后在 Docker Compose 中使用

标签: docker docker-compose


【解决方案1】:

是的,您可以通过使用 github 个人访问令牌 来实现这一点,它只有读取访问权限 https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token

然后你的令牌就是你的用户名,密码为空

喜欢, https://{token}@github.com/org_name/repo.git

【讨论】:

    猜你喜欢
    • 2018-01-05
    • 2015-01-01
    • 2016-06-24
    • 2021-06-19
    • 2021-08-22
    • 1970-01-01
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    相关资源
    最近更新 更多