mirror of
https://github.com/docker/compose.git
synced 2026-08-28 04:18:05 +00:00
Avoid rebinding tmpfs data volumes when recreating containers
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
da78c2c1db
commit
bbdbc35924
3 changed files with 37 additions and 9 deletions
|
|
@ -552,6 +552,24 @@ class ProjectTest(DockerClientTestCase):
|
|||
self.assertEqual(len(project.get_service('data').containers(stopped=True)), 1)
|
||||
self.assertEqual(len(project.get_service('console').containers()), 0)
|
||||
|
||||
def test_project_up_recreate_with_tmpfs_volume(self):
|
||||
# https://github.com/docker/compose/issues/4751
|
||||
project = Project.from_config(
|
||||
name='composetest',
|
||||
config_data=load_config({
|
||||
'version': '2.1',
|
||||
'services': {
|
||||
'foo': {
|
||||
'image': 'busybox:latest',
|
||||
'tmpfs': ['/dev/shm'],
|
||||
'volumes': ['/dev/shm']
|
||||
}
|
||||
}
|
||||
}), client=self.client
|
||||
)
|
||||
project.up()
|
||||
project.up(strategy=ConvergenceStrategy.always)
|
||||
|
||||
def test_unscale_after_restart(self):
|
||||
web = self.create_service('web')
|
||||
project = Project('composetest', [web], self.client)
|
||||
|
|
|
|||
|
|
@ -858,6 +858,7 @@ class ServiceVolumesTest(unittest.TestCase):
|
|||
'/new/volume',
|
||||
'/existing/volume',
|
||||
'named:/named/vol',
|
||||
'/dev/tmpfs'
|
||||
]]
|
||||
|
||||
self.mock_client.inspect_image.return_value = {
|
||||
|
|
@ -903,15 +904,18 @@ class ServiceVolumesTest(unittest.TestCase):
|
|||
VolumeSpec.parse('imagedata:/mnt/image/data:rw'),
|
||||
]
|
||||
|
||||
volumes = get_container_data_volumes(container, options)
|
||||
volumes = get_container_data_volumes(container, options, ['/dev/tmpfs'])
|
||||
assert sorted(volumes) == sorted(expected)
|
||||
|
||||
def test_merge_volume_bindings(self):
|
||||
options = [
|
||||
VolumeSpec.parse('/host/volume:/host/volume:ro', True),
|
||||
VolumeSpec.parse('/host/rw/volume:/host/rw/volume', True),
|
||||
VolumeSpec.parse('/new/volume', True),
|
||||
VolumeSpec.parse('/existing/volume', True),
|
||||
VolumeSpec.parse(v, True) for v in [
|
||||
'/host/volume:/host/volume:ro',
|
||||
'/host/rw/volume:/host/rw/volume',
|
||||
'/new/volume',
|
||||
'/existing/volume',
|
||||
'/dev/tmpfs'
|
||||
]
|
||||
]
|
||||
|
||||
self.mock_client.inspect_image.return_value = {
|
||||
|
|
@ -936,7 +940,7 @@ class ServiceVolumesTest(unittest.TestCase):
|
|||
'existingvolume:/existing/volume:rw',
|
||||
]
|
||||
|
||||
binds, affinity = merge_volume_bindings(options, previous_container)
|
||||
binds, affinity = merge_volume_bindings(options, ['/dev/tmpfs'], previous_container)
|
||||
assert sorted(binds) == sorted(expected)
|
||||
assert affinity == {'affinity:container': '=cdefab'}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue