@@ -108,6 +108,11 @@ func (c *container) PID() int {
108
108
109
109
func (c * container ) Hostname () string {
110
110
if c .container .Config .Domainname == "" {
111
+ // If hostname isn't set on a container it defaults to a random hex
112
+ // number which we don't want to show in the UI.
113
+ if strings .HasPrefix (c .container .ID , c .container .Config .Hostname ) {
114
+ return ""
115
+ }
111
116
return c .container .Config .Hostname
112
117
}
113
118
@@ -376,12 +381,14 @@ func (c *container) getSanitizedCommand() string {
376
381
377
382
func (c * container ) getBaseNode () report.Node {
378
383
result := report .MakeNodeWith (report .MakeContainerNodeID (c .ID ()), map [string ]string {
379
- ContainerID : c .ID (),
380
- ContainerCreated : c .container .Created .Format (time .RFC3339Nano ),
381
- ContainerCommand : c .getSanitizedCommand (),
382
- ImageID : c .Image (),
383
- ContainerHostname : c .Hostname (),
384
+ ContainerID : c .ID (),
385
+ ContainerCreated : c .container .Created .Format (time .RFC3339Nano ),
386
+ ContainerCommand : c .getSanitizedCommand (),
387
+ ImageID : c .Image (),
384
388
}).WithParent (report .ContainerImage , report .MakeContainerImageNodeID (c .Image ()))
389
+ if hostname := c .Hostname (); hostname != "" {
390
+ result = result .WithLatest (ContainerHostname , hostname )
391
+ }
385
392
result = result .AddPrefixPropertyList (LabelPrefix , c .container .Config .Labels )
386
393
if ! c .noEnvironmentVariables {
387
394
result = result .AddPrefixPropertyList (EnvPrefix , c .env ())
0 commit comments