Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compose/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def process_service(service_config):
if 'extra_hosts' in service_dict:
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:
service_dict[field] = to_list(service_dict[field])

Expand Down Expand Up @@ -730,7 +730,7 @@ def merge_service_dicts(base, override, version):
]:
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)

for field in set(ALLOWED_KEYS) - set(md):
Expand Down
1 change: 1 addition & 0 deletions compose/config/config_schema_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"shm_size": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"},
"stop_signal": {"type": "string"},
"tmpfs": {"$ref": "#/definitions/string_or_list"},
"tty": {"type": "boolean"},
"ulimits": {
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions compose/config/config_schema_v2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
"shm_size": {"type": ["number", "string"]},
"stdin_open": {"type": "boolean"},
"stop_signal": {"type": "string"},
"tmpfs": {"$ref": "#/definitions/string_or_list"},
"tty": {"type": "boolean"},
"ulimits": {
"type": "object",
Expand Down
1 change: 1 addition & 0 deletions compose/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ def _get_container_host_config(self, override_options, one_off=False):
cgroup_parent=options.get('cgroup_parent'),
cpu_quota=options.get('cpu_quota'),
shm_size=options.get('shm_size'),
tmpfs=options.get('tmpfs'),
)

def build(self, no_cache=False, pull=False, force_rm=False):
Expand Down
9 changes: 9 additions & 0 deletions docs/compose-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ Custom DNS search domains. Can be a single value or a list.
- dc1.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

Override the default entrypoint.
Expand Down
4 changes: 2 additions & 2 deletions docs/extends.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ replaces the old value.
> This is because `build` and `image` cannot be used together in a version 1
> file.

For the **multi-value options** `ports`, `expose`, `external_links`, `dns` and
`dns_search`, Compose concatenates both sets of values:
For the **multi-value options** `ports`, `expose`, `external_links`, `dns`,
`dns_search`, and `tmpfs`, Compose concatenates both sets of values:

# original service
expose:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cached-property==1.2.0
dockerpty==0.4.1
docopt==0.6.1
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
requests==2.7.0
six==1.7.3
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/project_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def test_up_with_network_static_addresses(self):
services=[{
'name': 'web',
'image': 'busybox:latest',
'command': 'top',
'networks': {
'static_test': {
'ipv4_address': '172.16.100.100',
Expand Down Expand Up @@ -690,7 +691,7 @@ def test_up_with_network_static_addresses(self):
name='composetest',
config_data=config_data,
)
project.up()
project.up(detached=True)

network = self.client.networks(names=['static_test'])[0]
service_container = project.get_service('web').containers()[0]
Expand Down
5 changes: 5 additions & 0 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,11 @@ def test_dns_search(self):
container = create_and_start_container(service)
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):
service = self.create_service('container', working_dir='/working/dir/sample')
container = service.create_container()
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/config/config_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,21 @@ def test_normalize_dns_options(self):
}
]

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):
base = {
'volumes': ['.:/app'],
Expand Down