我知道可以提供 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/