mirror of
https://github.com/docker/compose.git
synced 2025-07-20 12:14:41 +02:00
Add support for docker run --tmpfs flag.
Signed-off-by: Philip Walls <pawalls@rabidgeek.com>
This commit is contained in:
parent
25cbc2aae9
commit
85c7d3e5ce
@ -591,7 +591,7 @@ def process_service(service_config):
|
|||||||
if 'extra_hosts' in service_dict:
|
if 'extra_hosts' in service_dict:
|
||||||
service_dict['extra_hosts'] = parse_extra_hosts(service_dict['extra_hosts'])
|
service_dict['extra_hosts'] = parse_extra_hosts(service_dict['extra_hosts'])
|
||||||
|
|
||||||
for field in ['dns', 'dns_search']:
|
for field in ['dns', 'dns_search', 'tmpfs']:
|
||||||
if field in service_dict:
|
if field in service_dict:
|
||||||
service_dict[field] = to_list(service_dict[field])
|
service_dict[field] = to_list(service_dict[field])
|
||||||
|
|
||||||
@ -730,7 +730,7 @@ def merge_service_dicts(base, override, version):
|
|||||||
]:
|
]:
|
||||||
md.merge_field(field, operator.add, default=[])
|
md.merge_field(field, operator.add, default=[])
|
||||||
|
|
||||||
for field in ['dns', 'dns_search', 'env_file']:
|
for field in ['dns', 'dns_search', 'env_file', 'tmpfs']:
|
||||||
md.merge_field(field, merge_list_or_string)
|
md.merge_field(field, merge_list_or_string)
|
||||||
|
|
||||||
for field in set(ALLOWED_KEYS) - set(md):
|
for field in set(ALLOWED_KEYS) - set(md):
|
||||||
|
@ -104,6 +104,7 @@
|
|||||||
"shm_size": {"type": ["number", "string"]},
|
"shm_size": {"type": ["number", "string"]},
|
||||||
"stdin_open": {"type": "boolean"},
|
"stdin_open": {"type": "boolean"},
|
||||||
"stop_signal": {"type": "string"},
|
"stop_signal": {"type": "string"},
|
||||||
|
"tmpfs": {"$ref": "#/definitions/string_or_list"},
|
||||||
"tty": {"type": "boolean"},
|
"tty": {"type": "boolean"},
|
||||||
"ulimits": {
|
"ulimits": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -184,6 +184,7 @@
|
|||||||
"shm_size": {"type": ["number", "string"]},
|
"shm_size": {"type": ["number", "string"]},
|
||||||
"stdin_open": {"type": "boolean"},
|
"stdin_open": {"type": "boolean"},
|
||||||
"stop_signal": {"type": "string"},
|
"stop_signal": {"type": "string"},
|
||||||
|
"tmpfs": {"$ref": "#/definitions/string_or_list"},
|
||||||
"tty": {"type": "boolean"},
|
"tty": {"type": "boolean"},
|
||||||
"ulimits": {
|
"ulimits": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
|
@ -668,6 +668,7 @@ class Service(object):
|
|||||||
cgroup_parent=options.get('cgroup_parent'),
|
cgroup_parent=options.get('cgroup_parent'),
|
||||||
cpu_quota=options.get('cpu_quota'),
|
cpu_quota=options.get('cpu_quota'),
|
||||||
shm_size=options.get('shm_size'),
|
shm_size=options.get('shm_size'),
|
||||||
|
tmpfs=options.get('tmpfs'),
|
||||||
)
|
)
|
||||||
|
|
||||||
def build(self, no_cache=False, pull=False, force_rm=False):
|
def build(self, no_cache=False, pull=False, force_rm=False):
|
||||||
|
@ -226,6 +226,15 @@ Custom DNS search domains. Can be a single value or a list.
|
|||||||
- dc1.example.com
|
- dc1.example.com
|
||||||
- dc2.example.com
|
- dc2.example.com
|
||||||
|
|
||||||
|
### tmpfs
|
||||||
|
|
||||||
|
Mount a temporary file system inside the container. Can be a single value or a list.
|
||||||
|
|
||||||
|
tmpfs: /run
|
||||||
|
tmpfs:
|
||||||
|
- /run
|
||||||
|
- /tmp
|
||||||
|
|
||||||
### entrypoint
|
### entrypoint
|
||||||
|
|
||||||
Override the default entrypoint.
|
Override the default entrypoint.
|
||||||
|
@ -302,8 +302,8 @@ replaces the old value.
|
|||||||
> This is because `build` and `image` cannot be used together in a version 1
|
> This is because `build` and `image` cannot be used together in a version 1
|
||||||
> file.
|
> file.
|
||||||
|
|
||||||
For the **multi-value options** `ports`, `expose`, `external_links`, `dns` and
|
For the **multi-value options** `ports`, `expose`, `external_links`, `dns`,
|
||||||
`dns_search`, Compose concatenates both sets of values:
|
`dns_search`, and `tmpfs`, Compose concatenates both sets of values:
|
||||||
|
|
||||||
# original service
|
# original service
|
||||||
expose:
|
expose:
|
||||||
|
@ -3,7 +3,7 @@ cached-property==1.2.0
|
|||||||
dockerpty==0.4.1
|
dockerpty==0.4.1
|
||||||
docopt==0.6.1
|
docopt==0.6.1
|
||||||
enum34==1.0.4
|
enum34==1.0.4
|
||||||
git+https://github.com/docker/docker-py.git@d8be3e0fce60fbe25be088b64bccbcee83effdb1#egg=docker-py
|
git+https://github.com/docker/docker-py.git@8c4546f8c8f52bb2923834783a17beb5bb89a724#egg=docker-py
|
||||||
jsonschema==2.5.1
|
jsonschema==2.5.1
|
||||||
requests==2.7.0
|
requests==2.7.0
|
||||||
six==1.7.3
|
six==1.7.3
|
||||||
|
@ -875,6 +875,11 @@ class ServiceTest(DockerClientTestCase):
|
|||||||
container = create_and_start_container(service)
|
container = create_and_start_container(service)
|
||||||
self.assertEqual(container.get('HostConfig.DnsSearch'), ['dc1.example.com', 'dc2.example.com'])
|
self.assertEqual(container.get('HostConfig.DnsSearch'), ['dc1.example.com', 'dc2.example.com'])
|
||||||
|
|
||||||
|
def test_tmpfs(self):
|
||||||
|
service = self.create_service('web', tmpfs=['/run'])
|
||||||
|
container = create_and_start_container(service)
|
||||||
|
self.assertEqual(container.get('HostConfig.Tmpfs'), {'/run': ''})
|
||||||
|
|
||||||
def test_working_dir_param(self):
|
def test_working_dir_param(self):
|
||||||
service = self.create_service('container', working_dir='/working/dir/sample')
|
service = self.create_service('container', working_dir='/working/dir/sample')
|
||||||
container = service.create_container()
|
container = service.create_container()
|
||||||
|
@ -1194,6 +1194,21 @@ class ConfigTest(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
def test_tmpfs_option(self):
|
||||||
|
actual = config.load(build_config_details({
|
||||||
|
'web': {
|
||||||
|
'image': 'alpine',
|
||||||
|
'tmpfs': '/run',
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
assert actual.services == [
|
||||||
|
{
|
||||||
|
'name': 'web',
|
||||||
|
'image': 'alpine',
|
||||||
|
'tmpfs': ['/run'],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
def test_merge_service_dicts_from_files_with_extends_in_base(self):
|
||||||
base = {
|
base = {
|
||||||
'volumes': ['.:/app'],
|
'volumes': ['.:/app'],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user