using System;
using System.Diagnostics;
using Westwind.WebConnection;
namespace SFLoggerConsoleClient
{
public class EventPublisher
{
The first subnet of each docker bridge networks with their routes. It is supposed the sought IPv4 subnet is the first one (with index 0 in Config
map)
for n in $(docker network ls --format={{.ID}} --filter='driver=bridge'); do; printf "%s %-30s" $n $(docker inspect $n --format='{{.Name}}'); ip route | grep $(docker inspect $n --format='{{$value := index .IPAM.Config 0}}{{$value.Gateway}}'); done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{define "NetworkName"}}{{if eq .Name "bridge"}}{{else}}.{{.Name}}{{end}}{{end}} | |
{{define "Address"}}{{printf "%-27s" .}}{{end}} | |
{{$domain := "docker.unclev.ru"}} | |
{{range $key, $value := .}} | |
# Container: {{ $value.Name }} ({{$value.ID}} from {{$value.Image.Repository}}) | |
{{range $value.Networks}}{{if .Name}} | |
# Network: {{.Name}} {{if ne .Name "host"}}{{.Gateway}}{{if .IPPrefixLen}}/{{.IPPrefixLen}}{{end}} {{.IPv6Gateway}}{{if .GlobalIPv6PrefixLen}}/{{.GlobalIPv6PrefixLen}}{{end}} | |
{{if .GlobalIPv6Address}}{{template "Address" .GlobalIPv6Address}}{{$value.Hostname}}{{template "NetworkName" . }}.{{$domain}}{{end}} | |
{{if .IP }}{{template "Address" .IP }}{{$value.Hostname}}{{template "NetworkName" . }}.{{$domain}}{{end}} | |
{{if $value.Name -}} |