docker - 使用 docker-compose 从私有(private) GitHub 存储库构建 Docker 镜像

标签 docker docker-compose

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

version: '3.9'

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

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

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

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

最佳答案

是的,您可以使用仅具有读取权限的 github 个人访问 token 来实现此目的 https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token

然后你的 token 就是你的用户名和空密码

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

关于docker - 使用 docker-compose 从私有(private) GitHub 存储库构建 Docker 镜像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65312857/

相关文章:

node.js - 如何使用 docker-compose 运行 Express 和 Mongo

azure - 将伪 TTY 与 Azure 容器实例结合使用?

c++ - 我可以将具有依赖项的 C++ 库作为 Docker 镜像分发吗?

reactjs - 在 Docker 中运行时出现 Cypress 错误 "The automation client disconnected. Cannot continue running tests."

docker - 如何在docker-compose中设置docker卷的绝对路径?

django - 在 docker-compose : connection to postgres db refuses the first time but works afterwards 中运行 Django 应用程序

javascript - 如何修复运行 'cannot find module'错误的Docker容器?

docker - Linux Docker容器中的Application Insights SDK代理?

docker 组成 "ports": listen on multiple IP addresses/IP range

docker - AspNet Core无法在docker [“ASPNETCORE_ENVIRONMENT=Production”的生产环境中运行]