diff --git a/compose/config/config.py b/compose/config/config.py index 8cbaae272..72687d756 100644 --- a/compose/config/config.py +++ b/compose/config/config.py @@ -1033,8 +1033,11 @@ def resolve_volume_path(working_dir, volume): if isinstance(volume, dict): host_path = volume.get('source') container_path = volume.get('target') - if host_path and volume.get('read_only'): - container_path += ':ro' + if host_path: + if volume.get('read_only'): + container_path += ':ro' + if volume.get('volume', {}).get('nocopy'): + container_path += ':nocopy' else: container_path, host_path = split_path_mapping(volume) diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 14e6f7336..bceb102a2 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -374,7 +374,8 @@ class CLITestCase(DockerClientTestCase): 'volumes': [ '/host/path:/container/path:ro', 'foobar:/container/volumepath:rw', - '/anonymous' + '/anonymous', + 'foobar:/container/volumepath2:nocopy' ], 'stop_grace_period': '20s', diff --git a/tests/fixtures/v3-full/docker-compose.yml b/tests/fixtures/v3-full/docker-compose.yml index 27f3c6e04..2bc0e248d 100644 --- a/tests/fixtures/v3-full/docker-compose.yml +++ b/tests/fixtures/v3-full/docker-compose.yml @@ -44,6 +44,11 @@ services: target: /container/volumepath - type: volume target: /anonymous + - type: volume + source: foobar + target: /container/volumepath2 + volume: + nocopy: true stop_grace_period: 20s volumes: