mirror of
https://github.com/docker/compose.git
synced 2025-06-28 09:24:26 +02:00
Support legacy tmpfs mounts
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c4fda0834d
commit
397aa20dfc
@ -183,6 +183,10 @@ class MountSpec(object):
|
|||||||
def is_named_volume(self):
|
def is_named_volume(self):
|
||||||
return self.type == 'volume' and self.source
|
return self.type == 'volume' and self.source
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_tmpfs(self):
|
||||||
|
return self.type == 'tmpfs'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def external(self):
|
def external(self):
|
||||||
return self.source
|
return self.source
|
||||||
|
@ -834,8 +834,14 @@ class Service(object):
|
|||||||
if version_gte(self.client.api_version, '1.30'):
|
if version_gte(self.client.api_version, '1.30'):
|
||||||
override_options['mounts'] = [build_mount(v) for v in container_mounts] or None
|
override_options['mounts'] = [build_mount(v) for v in container_mounts] or None
|
||||||
else:
|
else:
|
||||||
override_options['binds'].extend(m.legacy_repr() for m in container_mounts)
|
# Workaround for 3.2 format
|
||||||
container_options['volumes'].update((m.target, {}) for m in container_mounts)
|
self.options['tmpfs'] = self.options.get('tmpfs') or []
|
||||||
|
for m in container_mounts:
|
||||||
|
if m.is_tmpfs:
|
||||||
|
self.options['tmpfs'].append(m.target)
|
||||||
|
else:
|
||||||
|
override_options['binds'].append(m.legacy_repr())
|
||||||
|
container_options['volumes'][m.target] = {}
|
||||||
|
|
||||||
secret_volumes = self.get_secret_volumes()
|
secret_volumes = self.get_secret_volumes()
|
||||||
if secret_volumes:
|
if secret_volumes:
|
||||||
|
@ -346,6 +346,21 @@ class ServiceTest(DockerClientTestCase):
|
|||||||
assert mount
|
assert mount
|
||||||
assert mount['Name'] == volume_name
|
assert mount['Name'] == volume_name
|
||||||
|
|
||||||
|
@v3_only()
|
||||||
|
def test_create_container_with_legacy_tmpfs_mount(self):
|
||||||
|
# Ensure tmpfs mounts are converted to tmpfs entries if API version < 1.30
|
||||||
|
# Needed to support long syntax in the 3.2 format
|
||||||
|
client = docker_client({}, version='1.25')
|
||||||
|
container_path = '/container-tmpfs'
|
||||||
|
service = Service('db', client=client, volumes=[
|
||||||
|
MountSpec(type='tmpfs', target=container_path)
|
||||||
|
], image='busybox:latest', command=['top'], project='composetest')
|
||||||
|
container = service.create_container()
|
||||||
|
service.start_container(container)
|
||||||
|
mount = container.get_mount(container_path)
|
||||||
|
assert mount is None
|
||||||
|
assert container_path in container.get('HostConfig.Tmpfs')
|
||||||
|
|
||||||
def test_create_container_with_healthcheck_config(self):
|
def test_create_container_with_healthcheck_config(self):
|
||||||
one_second = parse_nanoseconds_int('1s')
|
one_second = parse_nanoseconds_int('1s')
|
||||||
healthcheck = {
|
healthcheck = {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user