mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Merge remote-tracking branch 'stokito/browser'
This commit is contained in:
@ -141,6 +141,23 @@ func portsFormat(ports map[api.Port][]api.PortBinding) string {
|
||||
return strings.Join(append(exposed, published...), "\n")
|
||||
}
|
||||
|
||||
func webPort(ports map[api.Port][]api.PortBinding) string {
|
||||
for _, v := range ports {
|
||||
if len(v) == 0 {
|
||||
continue
|
||||
}
|
||||
for _, binding := range v {
|
||||
publishedIp := binding.HostIP
|
||||
if publishedIp == "0.0.0.0" {
|
||||
publishedIp = "localhost"
|
||||
}
|
||||
publishedWebPort := fmt.Sprintf("%s:%s", publishedIp, binding.HostPort)
|
||||
return publishedWebPort
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func ipsFormat(networks map[string]api.ContainerNetwork) string {
|
||||
var ips []string
|
||||
|
||||
@ -166,6 +183,10 @@ func (cm *Docker) refresh(c *container.Container) {
|
||||
c.SetMeta("image", insp.Config.Image)
|
||||
c.SetMeta("IPs", ipsFormat(insp.NetworkSettings.Networks))
|
||||
c.SetMeta("ports", portsFormat(insp.NetworkSettings.Ports))
|
||||
webPort := webPort(insp.NetworkSettings.Ports)
|
||||
if webPort != "" {
|
||||
c.SetMeta("Web Port", webPort)
|
||||
}
|
||||
c.SetMeta("created", insp.Created.Format("Mon Jan 2 15:04:05 2006"))
|
||||
c.SetMeta("uptime", calcUptime(insp))
|
||||
c.SetMeta("health", insp.State.Health.Status)
|
||||
|
Reference in New Issue
Block a user