diff --git a/docker/client.py b/docker/client.py index 936ab52cd..bb27a145e 100644 --- a/docker/client.py +++ b/docker/client.py @@ -408,7 +408,7 @@ def attach_socket(self, container, params=None, ws=False): def build(self, path=None, tag=None, quiet=False, fileobj=None, nocache=False, rm=False, stream=False, timeout=None, - custom_context=False, encoding=None): + custom_context=False, encoding=None, pull=True): remote = context = headers = None if path is None and fileobj is None: raise TypeError("Either path or fileobj needs to be provided.") @@ -441,7 +441,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None, 'remote': remote, 'q': quiet, 'nocache': nocache, - 'rm': rm + 'rm': rm, + 'pull': pull } if context is not None: diff --git a/docs/api.md b/docs/api.md index 6156ad95f..b49c0d592 100644 --- a/docs/api.md +++ b/docs/api.md @@ -58,6 +58,7 @@ build output as it happens * timeout (int): HTTP timeout * custom_context (bool): Optional if using `fileobj` * encoding (str): The encoding for a stream. Set to `gzip` for compressing +* pull (bool): Downloads any updates to the FROM image in Dockerfiles **Returns** (generator): A generator of the build output diff --git a/tests/test.py b/tests/test.py index 38cbc2f36..fc14977e3 100644 --- a/tests/test.py +++ b/tests/test.py @@ -1677,6 +1677,20 @@ def test_build_container(self): except Exception as e: self.fail('Command should not raise exception: {0}'.format(e)) + def test_build_container_pull(self): + script = io.BytesIO('\n'.join([ + 'FROM busybox', + 'MAINTAINER docker-py', + 'RUN mkdir -p /tmp/test', + 'EXPOSE 8080', + 'ADD https://dl.dropboxusercontent.com/u/20637798/silence.tar.gz' + ' /tmp/silence.tar.gz' + ]).encode('ascii')) + try: + self.client.build(fileobj=script, pull=True) + except Exception as e: + self.fail('Command should not raise exception: {0}'.format(e)) + def test_build_container_stream(self): script = io.BytesIO('\n'.join([ 'FROM busybox',