Unverified Kaydet (Commit) f83993de authored tarafından Ben Firshman's avatar Ben Firshman

Fix passing volumes to run with no host path

Technically we shouldn't be passing them as binds, but the daemon
doesn't seem to mind.

Fixes #1380
Signed-off-by: 's avatarBen Firshman <ben@firshman.co.uk>
üst 956fe1ca
......@@ -885,5 +885,15 @@ def _create_container_args(kwargs):
for p in sorted(port_bindings.keys())]
binds = create_kwargs['host_config'].get('Binds')
if binds:
create_kwargs['volumes'] = [v.split(':')[1] for v in binds]
create_kwargs['volumes'] = [_host_volume_from_bind(v) for v in binds]
return create_kwargs
def _host_volume_from_bind(bind):
bits = bind.split(':')
if len(bits) == 1:
return bits[0]
elif len(bits) == 2 and bits[1] in ('ro', 'rw'):
return bits[0]
else:
return bits[1]
......@@ -101,6 +101,8 @@ class ContainerCollectionTest(unittest.TestCase):
'/home/user1/:/mnt/vol2',
'/var/www:/mnt/vol1:ro',
'volumename:/mnt/vol3',
'/volumewithnohostpath',
'/anothervolumewithnohostpath:ro',
],
volumes_from=['container'],
working_dir='/code'
......@@ -118,6 +120,8 @@ class ContainerCollectionTest(unittest.TestCase):
'/home/user1/:/mnt/vol2',
'/var/www:/mnt/vol1:ro',
'volumename:/mnt/vol3',
'/volumewithnohostpath',
'/anothervolumewithnohostpath:ro'
],
'BlkioDeviceReadBps': [{'Path': 'foo', 'Rate': 3}],
'BlkioDeviceReadIOps': [{'Path': 'foo', 'Rate': 3}],
......@@ -183,7 +187,13 @@ class ContainerCollectionTest(unittest.TestCase):
tty=True,
user='bob',
volume_driver='some_driver',
volumes=['/mnt/vol2', '/mnt/vol1', '/mnt/vol3'],
volumes=[
'/mnt/vol2',
'/mnt/vol1',
'/mnt/vol3',
'/volumewithnohostpath',
'/anothervolumewithnohostpath'
],
working_dir='/code'
)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment