mirror of
https://github.com/docker/compose.git
synced 2025-07-22 21:24:38 +02:00
Merge pull request #3588 from shin-/3285-root-mount
Fix split_path_mapping behavior when mounting "/"
This commit is contained in:
commit
59e96fea4f
@ -940,9 +940,10 @@ def split_path_mapping(volume_path):
|
|||||||
path. Using splitdrive so windows absolute paths won't cause issues with
|
path. Using splitdrive so windows absolute paths won't cause issues with
|
||||||
splitting on ':'.
|
splitting on ':'.
|
||||||
"""
|
"""
|
||||||
# splitdrive has limitations when it comes to relative paths, so when it's
|
# splitdrive is very naive, so handle special cases where we can be sure
|
||||||
# relative, handle special case to set the drive to ''
|
# the first character is not a drive.
|
||||||
if volume_path.startswith('.') or volume_path.startswith('~'):
|
if (volume_path.startswith('.') or volume_path.startswith('~') or
|
||||||
|
volume_path.startswith('/')):
|
||||||
drive, volume_config = '', volume_path
|
drive, volume_config = '', volume_path
|
||||||
else:
|
else:
|
||||||
drive, volume_config = ntpath.splitdrive(volume_path)
|
drive, volume_config = ntpath.splitdrive(volume_path)
|
||||||
|
@ -2682,6 +2682,13 @@ class VolumePathTest(unittest.TestCase):
|
|||||||
mapping = config.split_path_mapping('{0}:{1}'.format(host_path, container_path))
|
mapping = config.split_path_mapping('{0}:{1}'.format(host_path, container_path))
|
||||||
assert mapping == expected_mapping
|
assert mapping == expected_mapping
|
||||||
|
|
||||||
|
def test_split_path_mapping_with_root_mount(self):
|
||||||
|
host_path = '/'
|
||||||
|
container_path = '/var/hostroot'
|
||||||
|
expected_mapping = (container_path, host_path)
|
||||||
|
mapping = config.split_path_mapping('{0}:{1}'.format(host_path, container_path))
|
||||||
|
assert mapping == expected_mapping
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
|
@pytest.mark.xfail(IS_WINDOWS_PLATFORM, reason='paths use slash')
|
||||||
class BuildPathTest(unittest.TestCase):
|
class BuildPathTest(unittest.TestCase):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user