From 5182bd0968473f9dd6af48900faf827c44d9ae89 Mon Sep 17 00:00:00 2001 From: Mohammad Salehe Date: Sun, 17 Aug 2014 17:48:24 +0430 Subject: [PATCH 1/2] Add dns_search support in yml config Signed-off-by: Mohammad Salehe --- docs/yml.md | 11 +++++++++++ fig/service.py | 5 ++++- tests/integration/service_test.py | 10 ++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/yml.md b/docs/yml.md index bd6914f8a..9ee2d27a3 100644 --- a/docs/yml.md +++ b/docs/yml.md @@ -171,6 +171,17 @@ cap_drop: - SYS_ADMIN ``` +### dns_search + +Custom DNS search domains. Can be a single value or a list. + +``` +dns_search: example.com +dns: + - dc1.example.com + - dc2.example.com +``` + ### working\_dir, entrypoint, user, hostname, domainname, mem\_limit, privileged, restart Each of these is a single value, analogous to its [docker run](https://docs.docker.com/reference/run/) counterpart. diff --git a/fig/service.py b/fig/service.py index 2abcc6d43..7c34be922 100644 --- a/fig/service.py +++ b/fig/service.py @@ -21,6 +21,7 @@ DOCKER_CONFIG_KEYS = [ 'command', 'detach', 'dns', + 'dns_search', 'domainname', 'entrypoint', 'env_file', @@ -284,6 +285,7 @@ class Service(object): privileged = options.get('privileged', False) net = options.get('net', 'bridge') dns = options.get('dns', None) + dns_search = options.get('dns_search', None) cap_add = options.get('cap_add', None) cap_drop = options.get('cap_drop', None) @@ -297,6 +299,7 @@ class Service(object): privileged=privileged, network_mode=net, dns=dns, + dns_search=dns_search, restart_policy=restart, cap_add=cap_add, cap_drop=cap_drop, @@ -407,7 +410,7 @@ class Service(object): container_options['image'] = self._get_image_name(container_options['image']) # Delete options which are only used when starting - for key in ['privileged', 'net', 'dns', 'restart', 'cap_add', 'cap_drop', 'env_file']: + for key in ['privileged', 'net', 'dns', 'dns_search', 'restart', 'cap_add', 'cap_drop', 'env_file']: if key in container_options: del container_options[key] diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 864b30a9f..d755b5afb 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -397,6 +397,16 @@ class ServiceTest(DockerClientTestCase): container = service.start_container().inspect() self.assertEqual(container['HostConfig']['CapDrop'], ['SYS_ADMIN', 'NET_ADMIN']) + def test_dns_search_single_value(self): + service = self.create_service('web', dns_search='example.com') + container = service.start_container().inspect() + self.assertEqual(container['HostConfig']['DnsSearch'], ['example.com']) + + def test_dns_search_list(self): + service = self.create_service('web', dns_search=['dc1.example.com', 'dc2.example.com']) + container = service.start_container().inspect() + self.assertEqual(container['HostConfig']['DnsSearch'], ['dc1.example.com', 'dc2.example.com']) + def test_working_dir_param(self): service = self.create_service('container', working_dir='/working/dir/sample') container = service.create_container().inspect() From 3c105c6db2902e786145d51ac21271265aa96282 Mon Sep 17 00:00:00 2001 From: Mohammad Salehe Date: Wed, 1 Oct 2014 20:10:50 +0330 Subject: [PATCH 2/2] Fix typo in dns_search documentation Signed-off-by: Mohammad Salehe --- docs/yml.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/yml.md b/docs/yml.md index 9ee2d27a3..a911e450b 100644 --- a/docs/yml.md +++ b/docs/yml.md @@ -177,7 +177,7 @@ Custom DNS search domains. Can be a single value or a list. ``` dns_search: example.com -dns: +dns_search: - dc1.example.com - dc2.example.com ```