Skip to content

Commit 3a32be7

Browse files
bo0tsshin-
authored andcommitted
Add and document a decode parameter for build
This makes the build method consistent with the events method and adds some convenience.
1 parent badc5b6 commit 3a32be7

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

docker/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ def attach_socket(self, container, params=None, ws=False):
307307
def build(self, path=None, tag=None, quiet=False, fileobj=None,
308308
nocache=False, rm=False, stream=False, timeout=None,
309309
custom_context=False, encoding=None, pull=True,
310-
forcerm=False, dockerfile=None, container_limits=None):
310+
forcerm=False, dockerfile=None, container_limits=None,
311+
decode=False):
311312
remote = context = headers = None
312313
container_limits = container_limits or {}
313314
if path is None and fileobj is None:
@@ -398,7 +399,7 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
398399
context.close()
399400

400401
if stream:
401-
return self._stream_helper(response)
402+
return self._stream_helper(response, decode=decode)
402403
else:
403404
output = self._result(response)
404405
srch = r'Successfully built ([0-9a-f]+)'

docs/api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ correct value (e.g `gzip`).
7171
- memswap (int): Total memory (memory + swap), -1 to disable swap
7272
- cpushares (int): CPU shares (relative weight)
7373
- cpusetcpus (str): CPUs in which to allow exection, e.g., `"0-3"`, `"0,1"`
74+
* decode (bool): If set to true, the returned stream will be decoded into dicts on the fly.
75+
False by default.
7476

7577
**Returns** (generator): A generator of the build output
7678

0 commit comments

Comments
 (0)