Skip to content

Commit a7cce1d

Browse files
committed
Merge pull request #421 from hammerdr/docker-build-pull
Allow for pull as an option to docker build
2 parents 4a7bb9a + 7426c52 commit a7cce1d

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

docker/client.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ def attach_socket(self, container, params=None, ws=False):
408408

409409
def build(self, path=None, tag=None, quiet=False, fileobj=None,
410410
nocache=False, rm=False, stream=False, timeout=None,
411-
custom_context=False, encoding=None):
411+
custom_context=False, encoding=None, pull=True):
412412
remote = context = headers = None
413413
if path is None and fileobj is None:
414414
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,
441441
'remote': remote,
442442
'q': quiet,
443443
'nocache': nocache,
444-
'rm': rm
444+
'rm': rm,
445+
'pull': pull
445446
}
446447

447448
if context is not None:

docs/api.md

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ build output as it happens
5858
* timeout (int): HTTP timeout
5959
* custom_context (bool): Optional if using `fileobj`
6060
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
61+
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
6162

6263
**Returns** (generator): A generator of the build output
6364

tests/test.py

+14
Original file line numberDiff line numberDiff line change
@@ -1677,6 +1677,20 @@ def test_build_container(self):
16771677
except Exception as e:
16781678
self.fail('Command should not raise exception: {0}'.format(e))
16791679

1680+
def test_build_container_pull(self):
1681+
script = io.BytesIO('\n'.join([
1682+
'FROM busybox',
1683+
'MAINTAINER docker-py',
1684+
'RUN mkdir -p /tmp/test',
1685+
'EXPOSE 8080',
1686+
'ADD https://dl.dropboxusercontent.com/u/20637798/silence.tar.gz'
1687+
' /tmp/silence.tar.gz'
1688+
]).encode('ascii'))
1689+
try:
1690+
self.client.build(fileobj=script, pull=True)
1691+
except Exception as e:
1692+
self.fail('Command should not raise exception: {0}'.format(e))
1693+
16801694
def test_build_container_stream(self):
16811695
script = io.BytesIO('\n'.join([
16821696
'FROM busybox',

0 commit comments

Comments
 (0)