有没有办法使用Github/GitLab下载Docker镜像?

4

由于Docker Hub仅允许1个私有repo,我想知道是否有任何方法可以使用Github或Gitlab等平台来下载镜像?例如:

FROM git@github.com/username/repo
...
...
...

GitHub肯定提供容器注册表:https://github.blog/2020-09-01-introducing-github-container-registry/ - jonrsharpe
1
你提到了Gitlab,它是一种托管解决方案,对吧?因此,如果您可以访问一台运行Gitlab的机器,那么您也可以轻松地在上面运行注册表。 - Hans Kilian
https://about.gitlab.com/blog/2020/10/30/mitigating-the-impact-of-docker-hub-pull-requests-limits/ - Jehof
我知道你已经在 Github 和 GitLab 上寻求解决方案,但我想推荐 AWS ECR,你只需要支付带宽费用。 - Juan Fontes
2个回答

1

gitlab.com上注册一个账户非常容易。GitLab提供了与项目相关的Docker registry,您可以拥有无限数量的私有项目:

  • Create a project my-docker-project
  • Go to Package and Registries > Container registries, you should see a few commands to access your registry
  • Connect your machine to this registry using a command like:
    # Will prompt for login/pass
    docker login registry.gitlab.com
    
    • You'll need an access token or deploy token with read_registry and write_registry scopes. You can generate one via your profile Preferences > Access token. Login is the token name and password the secret token provided.
  • You can now push Docker images with commands such as:
    # Push an image 
    docker push registry.gitlab.com/YourUsernameOrGroup/my-docker-project
    
    # Push an image on a sub-path
    docker push registry.gitlab.com/YourUsernameOrGroup/my-docker-project/myimage
    
您可以通过引用其URL在Dockerfile中使用该图像,例如:
FROM registry.gitlab.com/YourUsernameOrGroup/my-docker-project

# ...

当然,你使用的机器必须通过上面提到的docker login命令在相关的GitLab注册表上进行身份验证(或者项目必须是公开的)。

很好的回答,我有一个问题,如何将另一张图片包含在图片中...就像我们推送后怎么使用它? - dariush
1
当然,我已经编辑并附上了一个例子。 - Pierre B.

0

两者都拥有出色的软件包注册服务

对于GitHub GPR 对于GitLab GCR

两者都具有出色的功能,例如可以直接从Dockerfile中使用

我在Github上有一个公共示例,您可以查看它,其中使用GPR存储构建镜像/软件包的node.js。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接