def generate_hosts(config, app):
    '''
    app: {
        "container id": continer details
        ...
    }
    '''
#    hosts = {app[container]["NetworkSettings"]["IPAddress"]:app[container]["Name"].replace('/','') for container in app}
    hosts = {}
    for container in app:
        hosts[app[container]["NetworkSettings"]["IPAddress"]] = [app[container]["Name"].replace('/','')]
    for container in app:
        path = (app[container]["HostsPath"]
                if boot2docker.has() is not True
                else os.path.join(config["config_path"],"docker","containers",app[container]["Id"],"hosts"))
        try:
            with open(path, 'r+') as f:
                for host in hosts:
                    f.write("%s\t%s\n"%(host," ".join(hosts[host])))
        except Exception as e:
            utils.error(e)