diff --git a/fig/service.py b/fig/service.py index 3b66bc310ea..9d88a47cfeb 100644 --- a/fig/service.py +++ b/fig/service.py @@ -638,10 +638,19 @@ 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(':')]) + if isinstance(extra_hosts_config, basestring): + extra_hosts_config = [extra_hosts_config] + + extra_hosts_dict = {} + for extra_hosts_line in extra_hosts_config: + if isinstance(extra_hosts_line, dict): + # already interpreted as a dict (depends on pyyaml version) + extra_hosts_dict.update(extra_hosts_line) + else: + # not already interpreted as a dict + extra_hosts_dict.update(extra_hosts_line.split(':')) + + return extra_hosts_dict def merge_environment(options):