mirror of https://github.com/docker/docker-py.git
Merge pull request #421 from hammerdr/docker-build-pull
Allow for pull as an option to docker build
This commit is contained in:
commit
a7cce1d600
|
|
@ -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):
|
||||
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 @@ class Client(requests.Session):
|
|||
'remote': remote,
|
||||
'q': quiet,
|
||||
'nocache': nocache,
|
||||
'rm': rm
|
||||
'rm': rm,
|
||||
'pull': pull
|
||||
}
|
||||
|
||||
if context is not None:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue