Merge pull request #325 from orchardup/fix-dns

Fix and document `dns:` option
This commit is contained in:
Aanand Prasad 2014-07-17 18:34:12 -07:00
commit 12d75a74e6
3 changed files with 27 additions and 7 deletions

View File

@ -118,3 +118,14 @@ net: "none"
net: "container:[name or id]"
net: "host"
```
### dns
Custom DNS servers. Can be a single value or a list.
```
dns: 8.8.8.8
dns:
- 8.8.8.8
- 9.9.9.9
```

View File

@ -239,6 +239,7 @@ class Service(object):
privileged = options.get('privileged', False)
net = options.get('net', 'bridge')
dns = options.get('dns', None)
container.start(
links=self._get_links(link_to_self=override_options.get('one_off', False)),
@ -247,6 +248,7 @@ class Service(object):
volumes_from=self._get_volumes_from(intermediate_container),
privileged=privileged,
network_mode=net,
dns=dns,
)
return container
@ -347,13 +349,10 @@ class Service(object):
self.build()
container_options['image'] = self._build_tag_name()
# Priviliged is only required for starting containers, not for creating them
if 'privileged' in container_options:
del container_options['privileged']
# net is only required for starting containers, not for creating them
if 'net' in container_options:
del container_options['net']
# Delete options which are only used when starting
for key in ['privileged', 'net', 'dns']:
if key in container_options:
del container_options[key]
return container_options

View File

@ -316,6 +316,16 @@ class ServiceTest(DockerClientTestCase):
container = service.start_container().inspect()
self.assertEqual(container['HostConfig']['NetworkMode'], 'host')
def test_dns_single_value(self):
service = self.create_service('web', dns='8.8.8.8')
container = service.start_container().inspect()
self.assertEqual(container['HostConfig']['Dns'], ['8.8.8.8'])
def test_dns_list(self):
service = self.create_service('web', dns=['8.8.8.8', '9.9.9.9'])
container = service.start_container().inspect()
self.assertEqual(container['HostConfig']['Dns'], ['8.8.8.8', '9.9.9.9'])
def test_working_dir_param(self):
service = self.create_service('container', working_dir='/working/dir/sample')
container = service.create_container().inspect()