@@ -16,7 +16,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
1616 decode = False , buildargs = None , gzip = False , shmsize = None ,
1717 labels = None , cache_from = None , target = None , network_mode = None ,
1818 squash = None , extra_hosts = None , platform = None , isolation = None ,
19- use_config_proxy = True ):
19+ version = None , use_config_proxy = True ):
2020 """
2121 Similar to the ``docker build`` command. Either ``path`` or ``fileobj``
2222 needs to be set. ``path`` can be a local path (to a directory
@@ -101,6 +101,10 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
101101 platform (str): Platform in the format ``os[/arch[/variant]]``
102102 isolation (str): Isolation technology used during build.
103103 Default: `None`.
104+ version (str): Version of the builder backend to use.
105+ - `1` is the first generation classic (deprecated) builder in the Docker daemon (default)
106+ - `2` is [BuildKit](https://github.com/moby/buildkit)
107+ Default: `None`.
104108 use_config_proxy (bool): If ``True``, and if the docker client
105109 configuration file (``~/.docker/config.json`` by default)
106110 contains a proxy configuration, the corresponding environment
@@ -253,6 +257,13 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
253257 )
254258 params ['isolation' ] = isolation
255259
260+ if version is not None :
261+ if utils .version_lt (self ._version , '1.38' ):
262+ raise errors .InvalidVersion (
263+ 'version was only introduced in API version 1.38'
264+ )
265+ params ['version' ] = version
266+
256267 if context is not None :
257268 headers = {'Content-Type' : 'application/tar' }
258269 if encoding :
0 commit comments