Skip to content
Closed
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
11 changes: 11 additions & 0 deletions docs/yml.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,17 @@ dns:
- 9.9.9.9
```

### 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

Each of these is a single value, analogous to its [docker run](https://docs.docker.com/reference/run/) counterpart.
Expand Down
7 changes: 4 additions & 3 deletions fig/packages/docker/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def _result(self, response, json=False, binary=False):
def _container_config(self, image, command, hostname=None, user=None,
detach=False, stdin_open=False, tty=False,
mem_limit=0, ports=None, environment=None, dns=None,
volumes=None, volumes_from=None,
dns_search=None, volumes=None, volumes_from=None,
network_disabled=False, entrypoint=None,
cpu_shares=None, working_dir=None, domainname=None,
memswap_limit=0):
Expand Down Expand Up @@ -166,6 +166,7 @@ def _container_config(self, image, command, hostname=None, user=None,
'Env': environment,
'Cmd': command,
'Dns': dns,
'DnsSearch': dns_search,
'Image': image,
'Volumes': volumes,
'VolumesFrom': volumes_from,
Expand Down Expand Up @@ -449,14 +450,14 @@ def copy(self, container, resource):
def create_container(self, image, command=None, hostname=None, user=None,
detach=False, stdin_open=False, tty=False,
mem_limit=0, ports=None, environment=None, dns=None,
volumes=None, volumes_from=None,
dns_search=None, volumes=None, volumes_from=None,
network_disabled=False, name=None, entrypoint=None,
cpu_shares=None, working_dir=None, domainname=None,
memswap_limit=0):

config = self._container_config(
image, command, hostname, user, detach, stdin_open, tty, mem_limit,
ports, environment, dns, volumes, volumes_from, network_disabled,
ports, environment, dns, dns_search, volumes, volumes_from, network_disabled,
entrypoint, cpu_shares, working_dir, domainname, memswap_limit
)
return self.create_container_from_config(config, name)
Expand Down
7 changes: 4 additions & 3 deletions fig/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
log = logging.getLogger(__name__)


DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir']
DOCKER_CONFIG_KEYS = ['image', 'command', 'hostname', 'domainname', 'user', 'detach', 'stdin_open', 'tty', 'mem_limit', 'ports', 'environment', 'dns', 'dns_search', 'volumes', 'entrypoint', 'privileged', 'volumes_from', 'net', 'working_dir']
DOCKER_CONFIG_HINTS = {
'link' : 'links',
'port' : 'ports',
Expand Down Expand Up @@ -241,6 +241,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid
privileged = options.get('privileged', False)
net = options.get('net', 'bridge')
dns = options.get('dns', None)
dns_search = options.get('dns_search', None)

container.start(
links=self._get_links(link_to_self=override_options.get('one_off', False)),
Expand All @@ -249,7 +250,7 @@ def start_container(self, container=None, intermediate_container=None, **overrid
volumes_from=self._get_volumes_from(intermediate_container),
privileged=privileged,
network_mode=net,
dns=dns,
dns=dns, dns_search=dns_search
)
return container

Expand Down Expand Up @@ -351,7 +352,7 @@ def _get_container_create_options(self, override_options, one_off=False):
container_options['image'] = self._build_tag_name()

# Delete options which are only used when starting
for key in ['privileged', 'net', 'dns']:
for key in ['privileged', 'net', 'dns', 'dns_search']:
if key in container_options:
del container_options[key]

Expand Down
10 changes: 10 additions & 0 deletions tests/integration/service_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ def test_dns_list(self):
container = service.start_container().inspect()
self.assertEqual(container['HostConfig']['Dns'], ['8.8.8.8', '9.9.9.9'])

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()
Expand Down