-1

I'm looking to be able to build docker containers on the fly given a docker file. That is, given a docker file, I want to be able to send the file to a remote "build service", which builds it for me programatically. Are there any hosted or open source services that provide this?

Note that I'm not looking to build images on CI, but rather do something in code like this:

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

A simple rest API would be perfect. Any thoughts or ideas?

Jay K.
  • 546
  • 2
  • 10
  • 17
  • And what would be the `resp`? – Ali Tou Apr 26 '20 at 20:36
  • It doesn't really matter. What I'm looking for is an api to be able to build docker containers remotely. Whether the response is the contents of the image, or the url of the container is too important. – Jay K. Apr 26 '20 at 21:27

2 Answers2

1

I don't think there are such service providers by now. But you can use Docker SDK to build images for you. You can use their official Python library.

Also, you can inspire how Docker CLI itself triggers the builds.

For the sake of remoteness and being cloudy, check out the way this article mentions using a Kubernetes cluster to build your images: You can use K8s API to trigger a job that its container builds your Docker image.

Ali Tou
  • 2,009
  • 2
  • 18
  • 33
0

Seems like the best solution is to self-host something like kaniko. The post by @Ali Tou here seems like a more involved, but viable option.

Jay K.
  • 546
  • 2
  • 10
  • 17