Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for pull as an option to docker build #421

Merged
merged 2 commits into from
Dec 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down