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
6 changes: 6 additions & 0 deletions docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,12 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
if os.path.exists(dockerignore):
with open(dockerignore, 'r') as f:
exclude = list(filter(bool, f.read().split('\n')))
# These are handled by the docker daemon and should not be
# excluded on the client
if 'Dockerfile' in exclude:
exclude.remove('Dockerfile')
if '.dockerignore' in exclude:
exclude.remove(".dockerignore")
context = utils.tar(path, exclude=exclude)

if utils.compare_version('1.8', self._version) >= 0:
Expand Down
4 changes: 4 additions & 0 deletions tests/integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,8 @@ def runTest(self):
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
f.write("\n".join([
'node_modules',
'Dockerfile',
'.dockerginore',
'', # empty line
]))

Expand All @@ -1329,6 +1331,8 @@ def runTest(self):
chunk = chunk.decode('utf-8')
logs += chunk
self.assertFalse('node_modules' in logs)
self.assertFalse('Dockerfile' in logs)
self.assertFalse('.dockerginore' in logs)
self.assertTrue('not-ignored' in logs)

#######################
Expand Down