docker-py icon indicating copy to clipboard operation
docker-py copied to clipboard

Add support for building with buildkit

Open felipecrs opened this issue 6 months ago • 2 comments

Requires passing version='2' like:

stream = self.client.build(
    fileobj=dockerfile, tag='myimage', version='2'
)

Refs https://github.com/moby/moby/blob/3ff85c73436f1c4f8d9764a0d72e41a03b4116f5/api/swagger.yaml#L9343-L9352.

Closes #2230

felipecrs avatar Jun 27 '25 22:06 felipecrs

@thaJeztah do you think you can take a look at this one?

I know the PR backlog is full, but in my opinion this PR is a no-brainer and is of huge help (https://github.com/docker/docker-py/issues/2230 has 200+ upvotes).

felipecrs avatar Jun 29 '25 04:06 felipecrs

While this PR works, this bug in docker daemon API prevents it from being useful:

  • https://github.com/moby/moby/issues/48112

Because of that bug, any Dockerfile that refers to docker images that are not yet pulled will fail to build.

One workaround is to pull these images before invoking the build.

I haven't been able to work around it more cleanly.

I am no longer sure if this PR should be merged, but here are two reasons why it may be a good idea:

  1. There is a workaround (pull images in advance). Not ideal and not even easy, but it's better than nothing.
  2. This is not a problem that should be fixed in docker-py or any other client. Once it gets fixed in docker daemon API, the fix will be transparent for the client and will start working.

So, I will let maintainers of this project decide what is the best way forward.

felipecrs avatar Jul 01 '25 13:07 felipecrs