Skip to content

Commit 39ee598

Browse files
committed
Merge pull request #502 from cpuguy83/498_dockerignore_special_names
Add special cases for .dockerignore
2 parents 91985b2 + ce40730 commit 39ee598

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docker/client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,12 @@ def build(self, path=None, tag=None, quiet=False, fileobj=None,
297297
if os.path.exists(dockerignore):
298298
with open(dockerignore, 'r') as f:
299299
exclude = list(filter(bool, f.read().split('\n')))
300+
# These are handled by the docker daemon and should not be
301+
# excluded on the client
302+
if 'Dockerfile' in exclude:
303+
exclude.remove('Dockerfile')
304+
if '.dockerignore' in exclude:
305+
exclude.remove(".dockerignore")
300306
context = utils.tar(path, exclude=exclude)
301307

302308
if utils.compare_version('1.8', self._version) >= 0:

tests/integration_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,8 @@ def runTest(self):
13251325
with open(os.path.join(base_dir, '.dockerignore'), 'w') as f:
13261326
f.write("\n".join([
13271327
'node_modules',
1328+
'Dockerfile',
1329+
'.dockerginore',
13281330
'', # empty line
13291331
]))
13301332

@@ -1343,6 +1345,8 @@ def runTest(self):
13431345
chunk = chunk.decode('utf-8')
13441346
logs += chunk
13451347
self.assertFalse('node_modules' in logs)
1348+
self.assertFalse('Dockerfile' in logs)
1349+
self.assertFalse('.dockerginore' in logs)
13461350
self.assertTrue('not-ignored' in logs)
13471351

13481352
#######################

0 commit comments

Comments
 (0)