Allow for pull as an option to docker build

Signed-off-by: Derek Hammer <derek.r.hammer@gmail.com>
This commit is contained in:
Derek Hammer 2014-12-13 10:25:43 -08:00
parent 4a7bb9a9b0
commit d8e8400419
3 changed files with 17 additions and 1 deletions

View File

@ -408,7 +408,7 @@ class Client(requests.Session):
def build(self, path=None, tag=None, quiet=False, fileobj=None,
nocache=False, rm=False, stream=False, timeout=None,
custom_context=False, encoding=None):
pull=False, custom_context=False, encoding=None):
remote = context = headers = None
if path is None and fileobj is None:
raise TypeError("Either path or fileobj needs to be provided.")
@ -439,6 +439,7 @@ class Client(requests.Session):
params = {
't': tag,
'remote': remote,
'pull': pull,
'q': quiet,
'nocache': nocache,
'rm': rm

View File

@ -56,6 +56,7 @@ correct value (e.g `gzip`).
* stream (bool): Return a blocking generator you can iterate over to retrieve
build output as it happens
* timeout (int): HTTP timeout
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
* custom_context (bool): Optional if using `fileobj`
* encoding (str): The encoding for a stream. Set to `gzip` for compressing

View File

@ -1677,6 +1677,20 @@ class DockerClientTest(Cleanup, unittest.TestCase):
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',