Skip to content
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
10 changes: 8 additions & 2 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,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, pull=True,
forcerm=False):
forcerm=False, dockerfile=None):
remote = context = headers = None
if path is None and fileobj is None:
raise TypeError("Either path or fileobj needs to be provided.")
Expand All @@ -302,6 +302,11 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
if utils.compare_version('1.8', self._version) >= 0:
stream = True

if dockerfile and utils.compare_version('1.17', self._version) < 0:
raise errors.InvalidVersion(
'dockerfile was only introduced in API version 1.17'
)

u = self._url('/build')
params = {
't': tag,
Expand All @@ -310,7 +315,8 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
'nocache': nocache,
'rm': rm,
'forcerm': forcerm,
'pull': pull
'pull': pull,
'dockerfile': dockerfile
}

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 @@ -63,6 +63,7 @@ correct value (e.g `gzip`).
* encoding (str): The encoding for a stream. Set to `gzip` for compressing
* pull (bool): Downloads any updates to the FROM image in Dockerfiles
* forcerm (bool): Always remove intermediate containers, even after unsuccessful builds
* dockerfile (str): path within the build context to the Dockerfile

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

Expand Down
6 changes: 6 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2095,6 +2095,12 @@ def test_build_remote_with_registry_auth(self):
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))

def test_build_container_with_named_dockerfile(self):
try:
self.client.build('.', dockerfile='nameddockerfile')
except Exception as e:
self.fail('Command should not raise exception: {0}'.format(e))

#######################
# PY SPECIFIC TESTS #
#######################
Expand Down