Docker: 将 `docker build` 设置为服务

Docker: setting up `docker build` as a service

我希望能够在给定 docker 文件的情况下即时构建 docker 容器。也就是说,给定一个 docker 文件,我希望能够将该文件发送到远程 "build service",它以编程方式为我构建它。是否有提供此功能的托管或开源服务?

请注意,我不是要在 CI 上构建图像,而是在代码中做一些像这样的事情:

def build_image(dockerfile_contents):
    resp = docker_service.build(dockerfile_contents)
    ...

一个简单的休息API就完美了。有什么想法或想法吗?

我认为目前还没有这样的服务提供商。但是你可以使用 Docker SDK to build images for you. You can use their official Python library.

此外,您还可以启发 how Docker CLI itself triggers the builds

为了远程和多云,查看this article提及使用Kubernetes集群构建镜像的方式:您可以使用K8s API触发其容器构建的作业你的 Docker 图片。

似乎最好的解决方案是自行托管 kaniko. The post by @Ali Tou here 似乎是一个更复杂但可行的选择。