mirror of
https://github.com/costela/docker-etchosts.git
synced 2025-05-11 18:05:42 +02:00
Use extra_hosts instead of add_hosts
This commit is contained in:
parent
9847889000
commit
120c2ccb14
3 changed files with 6 additions and 4 deletions
|
@ -25,6 +25,8 @@ type dockerClientPinger interface {
|
|||
Ping(context.Context) (types.Ping, error)
|
||||
}
|
||||
|
||||
const dockerLabel string = "net.costela.docker-etchosts.extra_hosts";
|
||||
|
||||
func getAllIPsToNames(client dockerClienter) (ipsToNamesMap, error) {
|
||||
containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
|
||||
if err != nil {
|
||||
|
@ -90,7 +92,7 @@ func getIPsToNames(client dockerClienter, id string) (ipsToNamesMap, error) {
|
|||
names = appendNames(names, name)
|
||||
}
|
||||
|
||||
if label, ok := containerFull.Config.Labels["com.costela.docker-etchosts.add_hosts"]; ok {
|
||||
if label, ok := containerFull.Config.Labels[dockerLabel]; ok {
|
||||
if (strings.HasPrefix(label, "[")) {
|
||||
var parsed []string;
|
||||
err := json.Unmarshal([]byte(label), &parsed)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue