Skip to content

Generate hosts file with all IPs and hostnames for all containers #149

@mitar

Description

@mitar

I would like to generate an alternative /etc/hosts file with all IPs and hostnames for all containers. I will then use dnsmasq's --addn-hosts to read this file in and provide resolving of containers.

Currently, my template is:

{{ range $index, $container := $ }}
{{ $container.IP }} {{ $container.Hostname }}
{{ end }}

But with recent Docker additions I am not sure if this really lists all IPs for all containers and their hostnames. Doesn't container have multiple IPs in multiple networks? How could I list all IP from all networks and then for each of those IPs all hostnames? So hostname and also hostname.network_name?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions