added the extra_hosts option to the yml configuration which exposes the --add-host flag from the docker client
Signed-off-by: Sam Wing <sampwing@gmail.com>
This commit is contained in:
parent
e6ec76161d
commit
fb81c37ca6
4 changed files with 47 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ DOCKER_CONFIG_KEYS = [
|
|||
'entrypoint',
|
||||
'env_file',
|
||||
'environment',
|
||||
'extra_hosts',
|
||||
'hostname',
|
||||
'image',
|
||||
'links',
|
||||
|
|
@ -41,6 +42,7 @@ ALLOWED_KEYS = DOCKER_CONFIG_KEYS + [
|
|||
|
||||
DOCKER_CONFIG_HINTS = {
|
||||
'cpu_share': 'cpu_shares',
|
||||
'add_host': 'extra_hosts',
|
||||
'link': 'links',
|
||||
'port': 'ports',
|
||||
'privilege': 'privileged',
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ DOCKER_START_KEYS = [
|
|||
'dns',
|
||||
'dns_search',
|
||||
'env_file',
|
||||
'extra_hosts',
|
||||
'net',
|
||||
'pid',
|
||||
'privileged',
|
||||
|
|
@ -448,6 +449,8 @@ class Service(object):
|
|||
|
||||
restart = parse_restart_spec(options.get('restart', None))
|
||||
|
||||
extra_hosts = build_extra_hosts(options.get('extra_hosts', None))
|
||||
|
||||
return create_host_config(
|
||||
links=self._get_links(link_to_self=one_off),
|
||||
port_bindings=port_bindings,
|
||||
|
|
@ -460,6 +463,7 @@ class Service(object):
|
|||
restart_policy=restart,
|
||||
cap_add=cap_add,
|
||||
cap_drop=cap_drop,
|
||||
extra_hosts=extra_hosts,
|
||||
pid_mode=pid
|
||||
)
|
||||
|
||||
|
|
@ -619,3 +623,13 @@ def split_port(port):
|
|||
|
||||
external_ip, external_port, internal_port = parts
|
||||
return internal_port, (external_ip, external_port or None)
|
||||
|
||||
|
||||
def build_extra_hosts(extra_hosts_config):
|
||||
if extra_hosts_config is None:
|
||||
return None
|
||||
|
||||
if isinstance(extra_hosts_config, list):
|
||||
return dict(r.split(':') for r in extra_hosts_config)
|
||||
else:
|
||||
return dict([extra_hosts_config.split(':')])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue