瀏覽代碼

Support 'nocopy' mode for expanded volume syntax

Signed-off-by: Joffrey F <[email protected]>
Joffrey F 8 年之前
父節點
當前提交
eab1ee0eaf
共有 3 個文件被更改,包括 12 次插入3 次删除
  1. 5 2
      compose/config/config.py
  2. 2 1
      tests/acceptance/cli_test.py
  3. 5 0
      tests/fixtures/v3-full/docker-compose.yml

+ 5 - 2
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)
 

+ 2 - 1
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',

+ 5 - 0
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: