From 83dcceacafa720e55efa499485495c9f9dc59d93 Mon Sep 17 00:00:00 2001 From: Aanand Prasad Date: Tue, 24 Mar 2015 16:17:05 -0700 Subject: [PATCH] Fix regression in Dns and DnsSearch settings Signed-off-by: Aanand Prasad --- compose/service.py | 5 +++-- tests/integration/service_test.py | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/compose/service.py b/compose/service.py index 49e19cc56..936e3f9d0 100644 --- a/compose/service.py +++ b/compose/service.py @@ -6,6 +6,7 @@ import re import os from operator import attrgetter import sys +import six from docker.errors import APIError from docker.utils import create_host_config @@ -435,11 +436,11 @@ class Service(object): cap_drop = options.get('cap_drop', None) dns = options.get('dns', None) - if not isinstance(dns, list): + if isinstance(dns, six.string_types): dns = [dns] dns_search = options.get('dns_search', None) - if not isinstance(dns_search, list): + if isinstance(dns_search, six.string_types): dns_search = [dns_search] restart = parse_restart_spec(options.get('restart', None)) diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 7c1695624..f0fb771d9 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -424,6 +424,11 @@ class ServiceTest(DockerClientTestCase): container = create_and_start_container(service) self.assertEqual(container.get('HostConfig.NetworkMode'), 'host') + def test_dns_no_value(self): + service = self.create_service('web') + container = create_and_start_container(service) + self.assertIsNone(container.get('HostConfig.Dns')) + def test_dns_single_value(self): service = self.create_service('web', dns='8.8.8.8') container = create_and_start_container(service) @@ -455,6 +460,11 @@ class ServiceTest(DockerClientTestCase): container = create_and_start_container(service) self.assertEqual(container.get('HostConfig.CapDrop'), ['SYS_ADMIN', 'NET_ADMIN']) + def test_dns_search_no_value(self): + service = self.create_service('web') + container = create_and_start_container(service) + self.assertIsNone(container.get('HostConfig.DnsSearch')) + def test_dns_search_single_value(self): service = self.create_service('web', dns_search='example.com') container = create_and_start_container(service)