Skip to content

Commit

Permalink
Merge pull request #7328 from luHub/7242-fix-cli-no-labels
Browse files Browse the repository at this point in the history
Bug fix 7242 docker-compose with buildkit does not insert container labels
  • Loading branch information
Ulysses Souza authored Mar 31, 2020
2 parents aaef2d5 + 1a68828 commit 440c94e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,6 +1792,7 @@ def build(self, path, tag=None, quiet=False, fileobj=None,
command_builder.add_list("--cache-from", cache_from)
command_builder.add_arg("--file", dockerfile)
command_builder.add_flag("--force-rm", forcerm)
command_builder.add_params("--label", labels)
command_builder.add_arg("--memory", container_limits.get("memory"))
command_builder.add_flag("--no-cache", nocache)
command_builder.add_arg("--progress", self._progress)
Expand Down
17 changes: 17 additions & 0 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,23 @@ def test_build_cli(self):
self.addCleanup(self.client.remove_image, service.image_name)
assert self.client.inspect_image('composetest_web')

def test_build_cli_with_build_labels(self):
base_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, base_dir)

with open(os.path.join(base_dir, 'Dockerfile'), 'w') as f:
f.write("FROM busybox\n")

service = self.create_service('web',
build={
'context': base_dir,
'labels': {'com.docker.compose.test': 'true'}},
)
service.build(cli=True)
self.addCleanup(self.client.remove_image, service.image_name)
image = self.client.inspect_image('composetest_web')
assert image['Config']['Labels']['com.docker.compose.test']

def test_up_build_cli(self):
base_dir = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, base_dir)
Expand Down

0 comments on commit 440c94e

Please sign in to comment.