mirror of https://github.com/docker/compose.git
Merge pull request #325 from orchardup/fix-dns
Fix and document `dns:` option
This commit is contained in:
commit
12d75a74e6
11
docs/yml.md
11
docs/yml.md
|
@ -118,3 +118,14 @@ net: "none"
|
||||||
net: "container:[name or id]"
|
net: "container:[name or id]"
|
||||||
net: "host"
|
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
|
||||||
|
```
|
||||||
|
|
|
@ -239,6 +239,7 @@ class Service(object):
|
||||||
|
|
||||||
privileged = options.get('privileged', False)
|
privileged = options.get('privileged', False)
|
||||||
net = options.get('net', 'bridge')
|
net = options.get('net', 'bridge')
|
||||||
|
dns = options.get('dns', None)
|
||||||
|
|
||||||
container.start(
|
container.start(
|
||||||
links=self._get_links(link_to_self=override_options.get('one_off', False)),
|
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),
|
volumes_from=self._get_volumes_from(intermediate_container),
|
||||||
privileged=privileged,
|
privileged=privileged,
|
||||||
network_mode=net,
|
network_mode=net,
|
||||||
|
dns=dns,
|
||||||
)
|
)
|
||||||
return container
|
return container
|
||||||
|
|
||||||
|
@ -347,13 +349,10 @@ class Service(object):
|
||||||
self.build()
|
self.build()
|
||||||
container_options['image'] = self._build_tag_name()
|
container_options['image'] = self._build_tag_name()
|
||||||
|
|
||||||
# Priviliged is only required for starting containers, not for creating them
|
# Delete options which are only used when starting
|
||||||
if 'privileged' in container_options:
|
for key in ['privileged', 'net', 'dns']:
|
||||||
del container_options['privileged']
|
if key in container_options:
|
||||||
|
del container_options[key]
|
||||||
# net is only required for starting containers, not for creating them
|
|
||||||
if 'net' in container_options:
|
|
||||||
del container_options['net']
|
|
||||||
|
|
||||||
return container_options
|
return container_options
|
||||||
|
|
||||||
|
|
|
@ -316,6 +316,16 @@ class ServiceTest(DockerClientTestCase):
|
||||||
container = service.start_container().inspect()
|
container = service.start_container().inspect()
|
||||||
self.assertEqual(container['HostConfig']['NetworkMode'], 'host')
|
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):
|
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().inspect()
|
container = service.create_container().inspect()
|
||||||
|
|
Loading…
Reference in New Issue